R
R
Ruslan Kos2019-05-14 11:31:18
Docker
Ruslan Kos, 2019-05-14 11:31:18

Why do volumes in docker-compose overwrite the contents of a directory inside a container?

Ask a question
1
version: '3'
services:
web:
image: test/vitrina_20:$VITRINA_RELEASE
command: ['./init.sh']
volumes:
- /var/www/html/vitrina_20/static:/code/static
- /var/www/html/vitrina_20/media:/code/media
- /var/log/vitrina_20:/code/logs
ports:
- "8001:8000"
environment:
- DATANRM_URL
- DATANRM_USER
- DATANRM_PASS
There is a docker-compose file. 1. Why is the contents of the static folder inside the container overwritten when running the docker-compose.yml file? 2. How to make the contents of the /code/static folder in the form in which it exists in the repository be forwarded to the /var/www/html/vitrina_20/static folder on the host system? When not running, I can see the contents of the folder:
ls -1 static/
admin
bootstrap.bundle.min.js
bootstrap.min.css
bootstrap.min.js
debug_toolbar
favicon.ico
main.css
mptt
After running compose, when I go inside the container I I see that the contents of the folder are empty, and nevertheless, in the process of work, I can create some kind of file in static and it will be forwarded to the host system.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2019-05-14
@chupasaurus

Like any Unix-like system. In the mount namespace, the root is first mounted - the container image, and then the volumes, respectively, everything that was in the image along the mount path ceases to be available.
It is impossible to mount data from the image to the host, for you - docker cpafter starting the container

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question