Why docker command need sudo? | 为什么运行docker命令需要sudo?
Reference: https://stackoverflow.com/questions/51218233/docker-why-do-i-need-to-sudo-in-ubuntu
Docker: why do I need to sudo in Ubuntu?
I am working through this tutorial setting up Docker, and I’m finding that all of their examples are written like
docker run hello-worldbut when I try it, it says permission denied on a socket and I have to do
sudo docker run hello-worldto run the examples. Why are root privileges necessary even for these simple examples?
Answer
Running a docker container requires the user to be a member of the docker group. By default, when you install docker, the only user that is added to it is root. You can add your own user to this group if you want to run docker containers from it.
I overlooked that aspect of the setup, here are proper instructions: https://docs.docker.com/engine/install/linux-postinstall/
To create the docker group and add your user:
Create the docker group.
$ sudo groupadd dockerAdd your user to the docker group.
$ sudo usermod -aG docker $USERLog out and log back in so that your group membership is re-evaluated.
總結(jié)
以上是生活随笔為你收集整理的Why docker command need sudo? | 为什么运行docker命令需要sudo?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: leetcode 667. Beauti
- 下一篇: leetcode 75. Sort Co