第二个docker-compose上的命令未执行。

huangapple go评论61阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年6月6日 14:39:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412036.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定