简体   繁体   English

如何将 Bash 命令从 Python 传递到正在运行的 Docker 容器

[英]How to pass Bash commands from Python to a running Docker Container

I am running a Docker where I enter bash mode, and can input some commands.我正在运行一个进入 bash 模式的 Docker,并且可以输入一些命令。 While that Docker is running, is it possible to send these bash commands via a Python script?当 Docker 正在运行时,是否可以通过 Python 脚本发送这些 bash 命令?

This is a strange use case, but it seems necessary in this instance.这是一个奇怪的用例,但在这种情况下似乎是必要的。

Thanks a lot in advance!非常感谢!

For testing purposes is ok running commands inside the container, but for the general case, you should modify the ENTRYPOINT of the image for running the commands you want to.出于测试目的,可以在容器内运行命令,但对于一般情况,您应该修改映像的ENTRYPOINT以运行您想要的命令。

Also, you should define your use case, maybe it's not as strange as you think.另外,你应该定义你的用例,也许它没有你想象的那么奇怪。

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

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