[英]How to run python file after docker-compose in a shell script?
I want to run a python file after a docker-compose
file, which contains localstack.我想在包含 localstack 的 docker
docker-compose
文件之后运行一个 python 文件。 This is how I am trying:这就是我正在尝试的方式:
#!/bin/bash
docker-compose -f docker-compose.yml up
python main.py
After running the docker-compose file, it does not proceed to run my next command.运行 docker-compose 文件后,它不会继续运行我的下一个命令。 Can anyone help me to achieve the above?
谁能帮我实现上述目标?
The -d
argument to docker-compose up
will make it detach from the containers and return, so that other commands can run: docker-compose up
的-d
参数将使其与容器分离并返回,以便其他命令可以运行:
#!/bin/bash
docker-compose -f docker-compose.yml up -d
python main.py
Just make sure your other command does not run too early if it relies on the containers.如果它依赖于容器,请确保您的其他命令不会运行得太早。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.