Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

run docker as user not 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.
Comment

run docker as user not root

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

PREVIOUS NEXT
Code Example
Shell :: Jenkins ssh credentials in pipeline 
Shell :: clone repo with large size using git bash 
Shell :: Move folder content up a level using bash/shell 
Shell :: linux kill all process of a user 
Shell :: how to format pendrive on ubuntu 
Shell :: windows cat grep equivalent 
Shell :: mate on ubuntu 20.04 
Shell :: git push takes forever 
Shell :: how to install powershell 
Shell :: linux check if a group exist or not 
Shell :: git list untracked files 
Shell :: centos monitor network traffic 
Shell :: github desktop 
Shell :: install wordpress on centos 7 
Shell :: Git - create new branch and switch to that new branch 
Shell :: git clean local branches 
Shell :: vi quit 
Shell :: env file firebase 
Shell :: bash substract varible 
Shell :: tailwind installation 
Shell :: getcomposer.org download 
Shell :: bash here document example 
Shell :: duplicate wsl distro 
Shell :: get diff stash 
Shell :: install gitflow 
Shell :: ansible playbook omit tag 
Shell :: CMD-Digital Clook 
Shell :: pm2 how to make app start on boot 
Shell :: setting ssh for github 
Shell :: gchange default from dash to bash 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =