docker CMD 中的命令替换

cat*_*ory 2 python cmd command-substitution docker dockerfile

使用:

CMD ["$(pipenv --venv)/bin/python3", "main.py", "/root/uploads"]
Run Code Online (Sandbox Code Playgroud)

导致错误docker run

Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"$(pipenv --venv)/bin/python3\\\": stat $(pipenv --venv)/bin/python3: no such file or directory\"\n"
Run Code Online (Sandbox Code Playgroud)

$(pipenv --venv)/bin/python3有没有办法像CMD 部分那样进行评估命令替换?

Tar*_*ani 5

改成下面的

CMD ["bash", "-c", "$(pipenv --venv)/bin/python3 main.py /root/uploads"]
Run Code Online (Sandbox Code Playgroud)

如果这仍然给您带来问题,请更改$$$