简体   繁体   English

docker“无法找到组docker”使用“--group-add docker”

[英]docker "Unable to find group docker" using "--group-add docker"

I would like to know why --group-add docker in the following doesn't work.But I have another priority image that it does work.我想知道为什么下面的 --group --group-add docker docker 不起作用。但我有另一个优先图像,它确实起作用。

docker run \
    --rm \
    -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /etc/docker/daemon.json:/etc/docker/daemon.json \
    -v /etc/shadow:/etc/shadow \
    -v /etc/passwd:/etc/passwd \
    -v /etc/sudoers:/etc/sudoers \
    -v /etc/group:/etc/group \
    -u $(id -u):$(id -g) \
    --group-add docker \
    docker/compose:debian-1.27.4 \
    bash

it errors out它出错了

docker: Error response from daemon: Unable to find group docker.

I have the same issue with other images like ubuntu , hello-world and so on.我对ubuntuhello-world等其他图像也有同样的问题。 What is needed in the image to be able to add docker group?图像中需要什么才能添加docker组?

My system:我的系统:

  • Ubuntu 18.04 Ubuntu 18.04
  • docker 19.03.13码头工人 19.03.13

I know I have the docker group in the host.我知道我在主机中有docker组。 I can see it in the output of groups .我可以在groups的输出中看到它。

With you command, you are trying to add current user to the group docker , but inside docker, not in the host.使用您的命令,您正在尝试将当前用户添加到组docker ,但docker内部,而不是在主机中。

As group docker does not exist inside docker, reason why you've got error message.由于docker中不存在组docker ,因此您收到错误消息的原因。

If it's really what you want, you can use groupadd docker to create the group, then add the user to the group.如果确实是你想要的,你可以使用groupadd docker创建组,然后将用户添加到组中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM