after docker-compose up --build, I always get the error ‘python: can’t open file ‘run.py’: [Errno 2] No such file or directory’. If I remove the volumes, everything works as expected.
Any help is truly appreciated.
~ Pascal
It looks like the volume you’re trying to mount is the same directory that gets built into the container. My generic advice here is:
(1) Get a good developer environment set up on your host system
(2) Make sure all of your unit tests pass using pytest or whatever other framework you’re using
(3) Try to run your application locally
(4) Then run docker build and build/deploy your application for real; COPY it in a docker build step, don’t try to include it as a volume
That seems like a pretty clear error message. If you launch your container to a shell (IIRC, docker-compose run auth-service bash ) do you see the right directory contents? Does the very first line of run.py point at a directory that’s on your host but not in the container (#!/home/me/virtualenvs/auth/bin/python or something like that)?
Thanks for your response. Unfortunately I’m not quite understand your steps. What I try to achieve is to have this running locally. Auth service is part of a micro service. So there are other services as well, each one in his own machine and docker container. The all communicate with each other and have a nginx in front of it.
What I try to do is to create a local dev environment so that the flask server automatically restarts after a code change is detected. So it was my understanding that you have to mount the same folder.
After running ‘docker-compose run auth-service bash’ I can see the directory that run.py points too. However, I need this mounted to my host machine so I code changes are detected.
Hope this makes sense (: