在Docker容器中附加并运行命令 [英] Attach and run a command in a docker container
本文介绍了在Docker容器中附加并运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个运行/bin/bash的Docker容器
I have a docker container running /bin/bash
所以我可以附加它并运行类似的命令
So I can attach to it and run commands like
docker attach <container id>
bash# apt-get install package
有没有办法我可以在单个docker命令中执行此操作,也许是这样的:
Is there a way I can do this in a single docker command instead, maybe something like this:
docker attach <container id> "apt-get install package"
推荐答案
这应该有效.
echo'sudo apt-get install package'|复制代码码头工人附上<容器ID>
这篇关于在Docker容器中附加并运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文