command substitution in docker CMD

1k views Asked by At

Using:

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

Causes an error on 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"

Is there any way to make evaluate command substitutions like $(pipenv --venv)/bin/python3 in the CMD section?

1

There are 1 answers

0
Tarun Lalwani On BEST ANSWER

Change it to below

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

If that still gives you issue, change $ to $$