S
S
S1riyS2021-12-30 17:28:11
Docker
S1riyS, 2021-12-30 17:28:11

Why does the error "python: can't open file '/app/${FILENAME}': [Errno 2] No such file or directory" occur?

I have an image that runs python scripts, which takes an environment variable FILENAMEto know which script to run.

Dockerfile :

FROM python
ARG FILENAME_ARG
ENV FILENAME = $FILENAME_ARG
WORKDIR /app
COPY . .
CMD ["python", "${FILENAME}"]

In the console I enter the command:

docker run --env FILENAME=hello_world.py *Image ID*

An error occurs:

python: can't open file '/app/${FILENAME}': [Errno 2] No such file or directory


I assumed that by creating the container in this way, the variable FILENAME
would take on the value hello_world.py. But, apparently, something is going wrong.

Where is the mistake and how to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question