Host volumes Not set to "Docker-compose up"

I use docker-machine and docker-compose to develop a Django application with a React interface. The volumes are not mounted in the Debian environment, but they work fine on OSX and Windows, I have been struggling with this problem for many days, I created a light version of my project that still replicates the problem that you can find at https://github.com/firetix / docker_bug . my docker-compose.yml:

django: build: django volumes: - ./django/:/home/docker/django/ 

My docker file is as follows

 FROM python:2.7 RUN mkdir -p /home/docker/django/ ADD . /home/docker/django/ WORKDIR /home/docker/django/ CMD ["./command.sh"] 

When I start docker assembly, everything works correctly. But when I run docker-compose, I get

 [8] System error: exec: "./command.sh": stat ./command.sh: no such file or directory 

I found this question on stackoverflow How to mount local volumes in a docker machine after unsuccessful attempts to workarounds.

Am I doing something wrong? Why does this work on osx and windows, but not on a Debian environment? Is there a workaround that works in a Debian environment? Both Debian and OS have / Users / folders as a shared folder when checking the VirtualBox GUI.

+5
source share
2 answers

This should not work for you on OSX, but Debian alone. That's why:

When you add ./command.sh to /home/docker/django/django/ , the image builds fine and the file is in the correct directory. But when you up container, you set your local directory "on top" of the one you created in the image. So, there is nothing else ...

I recommend adding command.sh to another location, such as /opt/django/ or something similar, and changing the docker command to ./opt/command.sh .

Or simpler, something like this, here is the complete code:

 # Dockerfile FROM python:2.7 RUN mkdir -p /home/docker/django/ WORKDIR /home/docker/django/ # docker-compose.yml django: build: django command: ./command.sh volumes: - ./django/:/home/docker/django/ 
+1
source

I believe this should work. there were some issues with docker-compose versions using relative paths.

  django: build: django volumes: - ${PWD}/django:/home/docker/django 
0
source

Source: https://habr.com/ru/post/1247611/


All Articles