“Execute o docker como usuário não root” Respostas de código

Configurando o Docker como um usuário não raiz

##########################################
# Dockerfile to change from root to 
# non-root privilege
###########################################
# Base image is CentOS 7
FROM Centos:7
# Add a new user "john" with user id 8877
RUN useradd -u 8877 john
# Change to non-root privilege
USER john
Curious Cassowary

Execute o docker como usuário não root

#Add your user to the docker group
sudo usermod -aG docker [non-root user]
Ill Ibex

Execute o docker como usuário não root

# Edit the Dockerfile that creates a non-root privilege user and modify the default root user to the newly-created non-root privilege user, as shown here:

##########################################
# Dockerfile to change from root to 
# non-root privilege
###########################################
# Base image is CentOS 7
FROM Centos:7
# Add a new user "john" with user id 8877
RUN useradd -u 8877 john
# Change to non-root privilege
USER john

# 2. Proceed to build the Docker image using the “docker build” subcommand, as depicted here:

sudo docker build -t nonrootimage .

# 3. Finally, let’s verify the current user of our container using the id command in a docker run subcommand:

sudo docker run --rm nonrootimage id
# uid=8877(john) gid=8877(john) groups=8877(john)

# Evidently, the container’s user, group, and the groups are now changed to a non-root user.
Ill Ibex

Respostas semelhantes a “Execute o docker como usuário não root”

Perguntas semelhantes a “Execute o docker como usuário não root”

Mais respostas relacionadas para “Execute o docker como usuário não root” em Shell/Bash

Procure respostas de código populares por idioma

Procurar outros idiomas de código