After installing docker, there will usually be a docker user groupStep 2: Add the current user to the docker group sudo gpasswd -a ${USER} docker Step 3: Restart Docker sudo systemctl restart docker Step 4: Grant read and write permissions sudo chmod a+rw /var/run/docker.sock Supplement: Non-root users do not have permission to use docker No permission is prompted when running docker runOfficial documentation for installing Docker on CentOS The docker user group is automatically created when installing docker-ce, but you need to manually add users to the docker user group $ sudo usermod -aG docker $USER Or $ sudo usermod -aG docker {specify username} But after adding the user to the docker user group, it still prompts no permission For example, I want to run bash on Ubuntu 14.04: [hsowan@localhost shell-workspace]$ docker run -it --rm ubuntu:14.04 bash docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.38/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'. Why? The reason is that although the user has joined the docker user group, he has not switched to the docker user group, so he still has no permissions. If a user belongs to multiple user groups at the same time, the user can switch between user groups to have the permissions of other user groups. $ newgrp docker Now you can execute docker related commands under non-root users In addition to adding user groups to users, is there any other way to allow non-root users to execute docker-related commands? OK, let's check the permissions of /var/run/docker.sock $ sudo ll /var/run/docker.sock You will get the following result: srw-rw----. 1 root docker 0 Sep 22 15:29 /var/run/docker.sock So now directly modify the permissions of /var/run/docker.sock $ sudo chmod 666 /var/run/docker.sock Now you can run docker as a non-root user $ docker run -it --rm ubuntu:14.04 bash root@5c60abab6425:/# cat /etc/os-release NAME="Ubuntu" VERSION="14.04.5 LTS, Trusty Tahr" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 14.04.5 LTS" VERSION_ID="14.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" root@5c60abab6425:/# exit exit The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: MySQL online log library migration example
>>: Web front-end development course What are the web front-end development tools
The downloaded version is the Zip decompression v...
There is currently a requirement that an operatio...
Unzip the Maven package tar xf apache-maven-3.5.4...
Today, the company's springboot project is re...
This article shares the specific code of Node.js+...
need: The official website's resource server ...
Table of contents Preface 1. Style penetration 1....
Because I need to install MySQL, I record the ins...
Method 1: <input id= "File1" type= &q...
As we all know, SSH is currently the most reliabl...
Shell Script #!/bin/sh # Current directory CURREN...
Table of contents Problems encountered during dev...
Web forms are the primary communication channel b...
Table of contents 1. Interface definition 2. Attr...
Solution to MySQLSyntaxErrorException when connec...