“Jalankan Docker sebagai pengguna tidak root” Kode Jawaban

Mengatur Docker sebagai pengguna non root

##########################################
# 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

Jalankan Docker sebagai pengguna tidak root

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

Jalankan Docker sebagai pengguna tidak 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

Jawaban yang mirip dengan “Jalankan Docker sebagai pengguna tidak root”

Pertanyaan yang mirip dengan “Jalankan Docker sebagai pengguna tidak root”

Lebih banyak jawaban terkait untuk “Jalankan Docker sebagai pengguna tidak root” di Shell/Bash

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya