【发布时间】:2021-10-09 15:56:08
【问题描述】:
最近有人告诉我,使用 sudo 运行 docker 或 docker-compose 是一个很大的问题,我必须创建/添加我的用户到 docker 组才能运行 docker 和 docker-compose没有sudo 的命令。根据documentation here
现在,docker 通过我的用户正常运行。例如:
~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
但是当我尝试运行 docker-compose 时,我得到一个 Permission Denied
~$ docker-compose --help
-bash: /usr/local/bin/docker-compose: Permission denied
您能解释一下这是如何工作的吗?我认为有一个docker 组启用了这些命令的使用,因为二进制文件属于这个组,但实际上它们不属于,它们只属于root...
~$ ls -al /usr/bin/docker*
-rwxr-xr-x 1 root root 71706288 Jul 23 19:36 /usr/bin/docker
-rwxr-xr-x 1 root root 804408 Jul 23 19:36 /usr/bin/docker-init
-rwxr-xr-x 1 root root 2944247 Jul 23 19:36 /usr/bin/docker-proxy
-rwxr-xr-x 1 root root 116375640 Jul 23 19:36 /usr/bin/dockerd
~$ ls -al /usr/local/bin/
total 12448
drwxr-xr-x 2 root root 4096 May 26 11:08 .
drwxr-xr-x 10 root root 4096 May 14 19:36 ..
-rwxr--r-- 1 root root 12737304 May 26 11:08 docker-compose
那么,这是如何工作的?
以及如何让docker-compose 为属于docker 组的用户运行?
【问题讨论】:
标签: linux docker ubuntu docker-compose root