Answer the question
In order to leave comments, you need to log in
Why doesn't the python file ( /bin/sh: 1: [python,: not found) read in docker?
#Dockerfile
FROM python:3.6
RUN mkdir -p /usr/src/app/
WORKDIR /usr/src/app/
COPY . /usr/src/app/
CMD ["python", "app.py"]
#app.py
print('hello world')
error
Answer the question
In order to leave comments, you need to log in
CMD has 3 forms:
1. CMD ["executable","param1","param2"] - here you need the full path to the executable
2. CMD ["param1","param2"] - here are the ENTRYPOINT parameters
3. CMD command param1 param2 - this is just a command for the shell
Judging by the error, the third (!) form is used, the shell bites out the quotes and remains:
[python, app.py]
Bold showed the real name of the command that is passed to the shell.
Why is that? But I don't know. Old docker?
My test with such initial data was successful, despite the fact that I do not have a new version (17.05.0-ce).
[email protected] ~/dockers/test2 $ docker build -t pythontest .
Sending build context to Docker daemon 3.072kB
Step 1/5 : FROM python:3.6
---> 2dfb6d103623
Step 2/5 : RUN mkdir -p /usr/src/app/
---> Running in 09f00e2cd7c0
---> f7bf180ffc62
Removing intermediate container 09f00e2cd7c0
Step 3/5 : WORKDIR /usr/src/app/
---> a35eb6c2b4d2
Removing intermediate container 28981d13a074
Step 4/5 : COPY . /usr/src/app/
---> bf2cafb07143
Removing intermediate container 0553c72905cb
Step 5/5 : CMD python app.py
---> Running in 0e57967e6d8f
---> 5157a21343e9
Removing intermediate container 0e57967e6d8f
Successfully built 5157a21343e9
Successfully tagged pythontest:latest
[email protected] ~/dockers/test2 $ docker run -it --rm pythontest
hello world
[email protected] ~/dockers/test2 $
CMD needs double quotes, not single quotes!!
need "" - instead of ''
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question