[Django]-Why can "docker-compose run" create files outside the container?

4đź‘Ť

âś…

That’s because in your docker-compose.yml file you’re creating an image called web with a shared volume which maps your current directory (.) to /code directory of the created container.

volumes:
  - .:/code

That means that all files that are in /code directory (the directory where you create your project inside in the container) will be also in your local system under project directory.

Take a look to data volumes in Docker documentation to see things clearly:

https://docs.docker.com/engine/tutorials/dockervolumes/

👤kstromeiraos

1đź‘Ť

Because in the docker-compose.yml it’s defined a volume:

volumes:
       - .:/code

The “dot” before the colon means the current directory in your computer (host) relative to the Dockerfile and docker-compose.yml. And the /code is the directory inside the container.

👤wcomnisky

Leave a comment