如何从另一个容器中在容器中运行命令
我有一个Python脚本,可以使用其Docker Image运行phpstan( https:/ /docker )这样:
command = f"docker run --rm -v $PWD:/app ghcr.io/phpstan/phpstan --error-format=json analyse /app"
subprocess.Popen(f"{command}", stdout=subprocess.PIPE)
现在我想将所有内容扩展到一切。 我尝试创建一个Docker-Compose文件来创建两个容器,一个用于执行我的Python脚本,另一个执行PHPSTAN。
但是我找不到一种从我的python容器中拨打phpstan的方法。做什么的正确方法是什么?
目前,我发现的唯一解决方案是创建此Dockerfile,以将诗篇容器的所有内容复制到我的Python的容器中:
FROM ghcr.io/phpstan/phpstan:latest AS phpstan
FROM python:alpine AS python
COPY --from=phpstan / /
我打算在不同的容器中拥有多个工具,因为这些图像已经存在,然后从我的Python的脚本中调用它们容器。您有一个想法如何安全地做吗?
I have a Python script that runs PHPStan using their docker image (https://phpstan.org/user-guide/docker) like this:
command = f"docker run --rm -v $PWD:/app ghcr.io/phpstan/phpstan --error-format=json analyse /app"
subprocess.Popen(f"{command}", stdout=subprocess.PIPE)
Now I'd like to dockerize everything.
I tried to create a docker-compose file to create two containers, one to execute my Python script and the other to execute Phpstan.
But I do not find a way to call PHPStan from my Python container. What's the proper way to do it?
For now, the only solution I found is to create this Dockerfile to copy all the content of Psalm's container to my Python's container :
FROM ghcr.io/phpstan/phpstan:latest AS phpstan
FROM python:alpine AS python
COPY --from=phpstan / /
I intend to have multiple tools in different containers because the images already exist and then call them from a script in my Python's container. Do you have an idea how to do it securely?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论