skip to Main Content

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.

2

Answers


  1. 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)"]
    
    Login or Signup to reply.
  2. Your folder is created at the filesystem root : /

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search