需要编写一个在dock-a中安装docker的Dockerfile。 因为container-a需要执行docker命令到container-b,它与container-a一起运行。 我的理解是你在编写Dockerfile时不应该使用“sudo”。 但我陷入困境 - 我指派给docker组的用户是什么? 当您运行docker exec -it ,您将自动为root。
sudo usermod -a -G docker whatuser?
另外(我在集装箱内手动尝试这个 - 看它是否有效)你必须做一个newgrp docker来激活对组的更改。 我这样做的任何时候,当我没有sudo'ed时,我最终sudo'ing。 那有意义吗? 症状是 - 我去exit容器,我必须退出两次(好像我改变了用户)。
我究竟做错了什么?
Need to write a Dockerfile that installs docker in container-a. Because container-a needs to execute a docker command to container-b that's running alongside container-a. My understanding is you're not supposed to use "sudo" when writing the Dockerfile. But I'm getting stuck -- what user to I assign to docker group? When you run docker exec -it, you are automatically root.
sudo usermod -a -G docker whatuser?
Also (and I'm trying this out manually inside container-a to see if it even works) you have to do a newgrp docker to activate the changes to groups. Anytime I do that, I end up sudo'ing when I haven't sudo'ed. Does that make sense? The symptom is -- I go to exit the container, and I have to exit twice (as if I changed users).
What am I doing wrong?
最满意答案
如果您尝试将容器并排运行(不是容器内的容器),则应该从主机系统安装docker socket并以这种方式执行命令到其他容器:
docker run --name containera \ -v /var/run/docker.sock:/var/run/docker.sock \ yourimage安装了docker socket后,您可以控制主机系统上的docker。
If you are trying to run the containers alongside one another (not container inside container), you should mount the docker socket from the host system and execute commands to other containers that way:
docker run --name containera \ -v /var/run/docker.sock:/var/run/docker.sock \ yourimageWith the the docker socket mounted you can control docker on the host system.
更多推荐
发布评论