The Dockerfile causes the error.
Error response from daemon: dockerfile parse error line 4: COPY requires at least two arguments, but only one was provided. Destination could not be determined.
Is it because COPY command cannot split into multiple lines? What is the way to split into multiple lines then? There are examples for RUN
command using \ &&
but not sure of COPY
.
Dockerfile
FROM python:3.7-slim
WORKDIR /app
COPY [
"requirements.txt",
"serving/main.py",
"."
]
RUN pip install --upgrade -r requirements.txt
ENTRYPOINT ["python"]
CMD ["/app/main.py"]
I can put into one line but it is not readable.
COPY [ "requirements.txt", "serving/main.py", "training/simple_linear_regr_utils.py", "training/simple_linear_regr.py", "."]
CodePudding user response:
In a Dockerfile
, \
is the line continuation character. It can be used to split any directive across multiple physical lines. &&
has nothing to do with Dockerfile
syntax; that's shell syntax is only relevant in RUN
lines (which are executed by the shell).
So you can write:
COPY requirements.txt \
serving/main.py \
.
But! That probably won't do what you want, in that you'll end up with a directory that looks like:
/app
├── main.py
└── requirements.txt
That is, it copies everything into the same directory without preserving the directory hierarchy (but so does your COPY [ ... ]
version).