Home > Software engineering >  Where the new folder is created when using Dockerfile
Where the new folder is created when using Dockerfile

Time:09-15

Please help me understand where the new folder is created. When I docker exec -it <mycontainer> bash the container, the created folder is not there.

Dockerfile:

FROM python:3.7-alpine
WORKDIR /app
RUN pip install -r requirements.txt
RUN mkdir -p /new_folder
COPY . .
CMD ["gunicorn", "-w 4", "main:app"]

I also tried copying the local stuff before creating a new folder, still can't see the folder created in the container.

CodePudding user response:

your working directory is /app and you are copying files from your current dierctory to /app. when your container is running do this

docker exec -it <container_id> pwd

you'll see /app in output but you are creating new_folder as a root directory. so you can't see it inside /app enter image description here

to see your root directories you can run this:

docker exec -it container_id /bin/sh -c "ls -lah ..

also my Dockerfile is this:

FROM python:3.7-alpine
WORKDIR /app
RUN mkdir -p /new_folder
COPY . .
CMD ["python" , "-c" , "import time; time.sleep(10000)"]

CodePudding user response:

Your folder is created at the filesystem root : /

try docker exec -it <mycontainer> bash and then, in the container, ls /

  • Related