docker CMD中的命令替换

时间:2017-09-11 09:28:39

标签: python docker cmd dockerfile command-substitution

使用:

CMD ["$(pipenv --venv)/bin/python3", "main.py", "/root/uploads"]

导致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"

有没有办法在CMD部分进行评估命令替换,如$(pipenv --venv)/bin/python3

1 个答案:

答案 0 :(得分:1)

将其更改为

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

如果仍有问题,请将$更改为$$