英文:
Second command on docker-compose is not executed
问题
以下是要翻译的内容:
我有以下的docker-compose文件,在命令部分有两个命令。第一个用于升级pip3,第二个用于安装Python项目的依赖项。
version: '3'
services:
remote_interpreter :
image: amazon/aws-glue-libs:glue_libs_3.0.0_image_01
entrypoint: ""
command: "pip3 install --upgrade pip && pip3 install -r ./tests/requirements.txt"
然而,当我运行docker-compose -f ./my-file.yaml up
时,我没有看到requirements.txt中的包被安装。
另外,我如何保持基于这个docker-compose文件构建的容器运行,以便我可以检查是否真正安装了所需的包?
英文:
I have the following docker-compose file. and in the command part, i have 2 commands. The first one is for upgrading the pip3 and the second one to install requeriment of the python project.
version: '3'
services:
remote_interpreter :
image: amazon/aws-glue-libs:glue_libs_3.0.0_image_01
entrypoint: ""
command: "pip3 install --upgrade pip && pip3 install -r ./tests/requirements.txt"
However, when i run the docker-compose -f ./my-file.yaml up
, i don't see the packages inside the requirements.txt are being installed.
Also, how i can keep the container which is built on based this docker-compose file running, so that i can check if the needed packages are really installed ?
答案1
得分: 0
你需要将你的命令包装在一个单独的 shell 中。尝试这样做:
command: sh -c "pip3 install --upgrade pip && pip3 install -r ./tests/requirements.txt"
更多信息请查看https://www.baeldung.com/ops/docker-compose-multiple-commands
英文:
You need to wrap your commands in a single shell. Try this:
command: sh -c "pip3 install --upgrade pip && pip3 install -r ./tests/requirements.txt"
More info at https://www.baeldung.com/ops/docker-compose-multiple-commands
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论