[英]Can I run docker diff from a container on the same host as the container I want to run the diff on?
I have two containers running on a host. 我有两个在主机上运行的容器。 When I'm in container AI want to run a diff on container B compared to it's image to see what has changed in the filesystem.
当我进入容器AI时,要对容器B进行比较(与它的映像相比),以查看文件系统中发生了什么变化。 I know this can be ran easily from the host itself, but I'm wondering is there any way of doing this from inside container A, to see the difference on container B?
我知道可以很容易地从主机本身运行它,但是我想知道是否有任何方法可以从容器A内部执行此操作,以查看容器B上的区别?
You can run any docker commands from within container which will communicate with host docker daemon if: 您可以在容器内运行将与主机docker守护程序通信的容器中的任何docker命令,如果:
You can achieve first condition by mounting docker socket to container - add following to your docker run
call: -v /var/run/docker.sock:/var/run/docker.sock
. 您可以通过将docker套接字安装到容器来实现第一个条件-在
docker run
调用中添加以下内容: -v /var/run/docker.sock:/var/run/docker.sock
。
The second condition depends on your docker image. 第二个条件取决于您的docker映像。
If you are running bare Ubuntu image you can have shell inside container which will be able to do what you want with following command: 如果您运行的是裸露的Ubuntu映像,则可以在容器中包含外壳程序,该外壳程序将可以通过以下命令执行所需的操作:
docker run -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:latest sh -c "apt-get update ; apt-get install docker.io -y ; bash"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.