Home > Software design >  Docker arguments work w/ COPY but not ADD
Docker arguments work w/ COPY but not ADD

Time:11-07

Got this solved!

I learned my smart quotes lesson the hard way...

Although, now that I know this- I find it crazy that Docker themselves used smart quotes in this tutorial: https://www.docker.com/blog/how-to-dockerize-your-python-applications/


Just want to figure this out for my edification..

Just learning Docker and getting a "Hello World" in Python working...

My Dockerfile:

# FROM python:3.11
# ADD main.py .
# CMD [“python”, “./main.py”]

FROM python:3.11
COPY main.py .
CMD ["python", "./main.py"]

Main.py

print("Hello World")

It works fine with COPY (as is), but when I build/run with ADD I get:

/bin/sh: 1: [“python”,: not found

What am I missing?

From what I understand, these should be doing the same thing...

CodePudding user response:

It's not the ADD or COPY causing this issue, it's the two different CMD statements you're using:

  • CMD [“python”, “./main.py”]
  • CMD ["python", "./main.py"]

Replace the smart quotes with normal quotes, and you should be good.

  • Related