4

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

3
  • Is the myworker.py file in the ./backend/ folder? Commented Feb 17, 2016 at 19:55
  • Your example in github does not have a backend folder. Have you just made a path mistake? Commented Feb 17, 2016 at 21:20
  • I know but this is a work in progress, what I was doing is moving the app and myworker to separate folders but tis is not yet pushed as not to pollute the repo. However, I will push it now. Commented Feb 18, 2016 at 8:34

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

5 Comments

I know but this is a work in progress, what I was doing is moving the app and myworker to separate folders but tis is not yet pushed as not to pollute the repo. However, I will push it now.
I tested your Dockerfile and it looks like is working now, Still do you have problem moving the file into container? Still your question is valid?
If still you have problems moving the file, it could be a cache problem, you could try to build the image again using the flag --no-cache
No, still same problem. When I run this repo with "docker-compose up", I get "ImportError: No module named myworker" from the frontend. Maybe I should inform you that I'm on OSX and hence the docker host is a VM? Maybe there is a difference with your setup? I installed 1.10.1a of the toolbox hoping this would solve it but no it does not.
I cannot thank you enough @HemersonVarela for pointing that out. I had a feeling something like that was happening. So, I gave it a thought and updated the repo to v0.3 github.com/AvidSoftware-be/docker-compose-test/tree/0.3 Now the whole test is working!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.