Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Docker ADD command not copy this file?

In the file below, the file apprequirements.txt is ADDed to the container. I know because pip install works. However, the myworker.py file is not copied/added. Why?

FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD ./frontend/apprequirements.txt /code
RUN pip install -r apprequirements.txt
ADD ./backend/myworker.py /code

I run this with docker-compose, you can see the whole example on https://github.com/AvidSoftware-be/Docker-compose-test

like image 390
Dennis Decoene Avatar asked Oct 28 '25 17:10

Dennis Decoene


1 Answers

After a deep review into your repo, this is my conclusion:

Your Dockerfile is fine, it does what is supposed to do. It creates an image, inside that image a folder /code was created and two files were copied apprequirements.txt and myworker.py.

Inside the docker-compose.yml file you have this line:

volumes:
  - ./frontend:/code

This means that after you run the docker-compose up command, docker is going to mount a volumen over the /code existing directory.

The content of /code isn't removed from the container, however it is "masked", because the mounted directory is mounted on top of the existing files. The files are still in the container, but there are not reachable.

Note: the folder ./frontend includes the file 'apprequirements.txt' is why you believe that only one file was added.

like image 121
Hemerson Varela Avatar answered Oct 31 '25 06:10

Hemerson Varela