Reputation: 2449
I have a front end project which includes package.json
inside it.(imagine create-react-app
for example)
When I run below command everything works fine with no error.
first DockerFile
COPY . develop
WORKDIR develop
But in case I want COPY
, package.json
next command I will face an error.
second DockerFile
COPY package.json develop
WORKDIR develop
error message: Cannot mkdir: /develop is not a directory
I know how to dockerize my project with the below command.
WORKDIR develop
COPY package.json .
I am just curious to know why the first Dockerfile works and the second one won't work.
I also used RUN ls
after COPY
command and find out in both case the develop
directory has been generated.
Upvotes: 0
Views: 56
Reputation: 1409
It is because COPY package.json develop
is instructed to copy the packages.json to the container as develop. So the next directive WORKDIR fails because develop is not a directory but a file.
Use the / before && after develop and it should work.
FROM alpine
COPY temp.txt /develop/
WORKDIR develop
Upvotes: 2