在链接的Docker容器中执行命令 [英] Execute command in linked docker container

查看:92
本文介绍了在链接的Docker容器中执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从链接的Docker容器中的一个Docker容器内部可以执行exec命令吗?
我不想从主机执行命令。

Is there any way posible to exec command from inside one docker container in the linked docker container? I don't want to exec command from the host.

推荐答案

只要您可以访问以下内容容器中的docker套接字,无论是否链接,都可以在任何Docker容器中运行任何命令。例如:

As long as you have access to something like the docker socket within your container, you can run any command inside any docker container, doesn't matter whether or not it is linked. For example:

# run a container and link it to `other`
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock \
           --link other:other myimage bash -l
bash$ docker exec --it other echo hello

即使未指定链接也可以使用。

This works even if the link was not specified.

这篇关于在链接的Docker容器中执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆