Question

Issues with Volume in Docker - Compose Fail to install Django App.

I am trying to install an application from github to my droplet and the Docker-compose.yml file includes mapping volumes.

The github location for the app is www.github.com/18f/tock which has the following instruction to set up the up using the docker console.

$ cp .env.sample .env
$ docker-compose build
$ docker-compose run app python manage.py migrate
$ docker-compose run app python manage.py loaddata test_data/data-update.json

The thing works perfectly on the local machine and I was able to get it working in the local docker installation. Here is a link I am using to https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/

app:
build: .
volumes:
- ./tock:/tock
links:
- db
working_dir: /tock
entrypoint: python /tock/docker_entrypoint.py
environment:
- PYTHONUNBUFFERED=yup
- DATABASE_URL=postgres://tock_user@db/tock
- RUNNING_IN_DOCKER=yup
- DJANGO_SETTINGS_MODULE=tock.settings.dev
command: "python manage.py runserver 0.0.0.0:${EXTERNAL_PORT}"

However when I run the docker-compose run app python manage.py migrate statement, it says that the /tock/docker_entrypoint.py file not found.

python: can't open file '/tock/docker_entrypoint.py': [Errno 2] No such file or directory

Google results indicate that the mount of the volume is not working and I am trying to find out how to confirm that the volume is being mounted.

On running docker volume ls I am seeing a bunch of volumes but the names are not consistent.

Also when I look at the volumes section I see that the Name of the volume is not tock but some random guid.

docker volume inspect e32d8cdf9a61015bc4230781878c715ef56cf6c47536e17c75721c6a47455204
[
    {
        "Name": "e32d8cdf9a61015bc4230781878c715ef56cf6c47536e17c75721c6a47455204",
        "Driver": "local",
        "Mountpoint": "/var/lib/docker/volumes/e32d8cdf9a61015bc4230781878c715ef56cf6c47536e17c75721c6a47455204/_data",
        "Labels": null
    }
]

I am a newbie and have been trying to get this working but with no luck as the mount does not work.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @gndo:

@vinitpatankar - I believe the image is using the default CMD, which is to run docker_entrypoint.py in the current WORKDIR. To test this, add this to the end of your Dockerfile:

# Override test of default command to port 9876
CMD  ["python", "manage.py", "runserver", "0.0.0.0:9876"]

The error message you’re seeing now should go away, though you may get a new message once it runs.

View the original comment