Docker Community Forums

Share and learn in the Docker community.

Unable to find the file while docker run

FROM centos

RUN mkdir /test
COPY ./ /test

CMD [“sh”, “/test/”]

Docker Run:
docker run -d -p 8081:8080 --name Test -v /home/Docker/Container_File_System:/test test:v1

Here 2 problems:
The output says
sh: /test/ No such file or directory

Also, as I have mapped a host folder to container folder, I was expecting the test folder & the to be available at /home/Docker/Container_File_System post run, which did not happen.

Any help is appreciated.

You’re copying your local /app/ folder to the /app/ folder in the running Docker container (as mentioned in the comments) creating /app/app/ in the Docker container.

How to resolve
A simple fix will be to change

COPY . /app

COPY ./app/ /app/
The command COPY works as follows:

You’re selecting everything in the folder where the Dockerfile resides, by using . in your first COPY, thereby selecting the local /app folder to be added to the Docker’s folder. The destination you’re allocating for it in the Docker container is also /app and thus the path in the running container becomes /app/app/… explaining why you can’t find the file.