Docker-compose volumes are not mounted on host directories

I use docker-compose for deployment with installation 2 docker-compose.yml, where I create the image locally and pull it from the dock on the server.

In addition to building and pulling the image, the configuration of the volumes is the same.

Locally:

app:
  build: .
  volumes:
    - "/data/volume:/volume"

And on the server:

app:
  image: username/repo:tag
  volumes:
    - "/data/volume:/volume"

In my Docker file:

volume /volume

Locally, my volume is mounted in the specified directory, files created by the application are saved there outside the container. However, this does not happen on the deployment server.

Files but they are created and saved during deployment, although my deployment script works docker-compose down -v, which supposedly deletes named and anonymous volumes in the container.

, - , , . ? .

:

. :

docker-compose down -v --rmi all --remove-orphans
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)

... , , , :

docker pull username/repo:tag
docker-compose build --no-cache --force-rm
docker-compose up -d

... , , , , , . ?

docker inspect <container> :

"Mounts": [
  "Source": "/data/volume",
  "Destination": "/volume",
  "Mode": "rw",
  "RW": true,
  "Propagation": "rprivate"
]

, "rprivate", .

+7
4

, EBS /volume , Docker.

, docker inspect , , .

Docker, , , , Docker , .

Docker.

+5

, Windows, Docker C :. , .

Hyper-V (Docker Windows):

  • "" → " ", "C:" ()

. VirtualBox:

  • VBoxManage sharedfolder add default --name c --hostpath /c --automount ()
+5

/data/volume 777 , . - Linux-? , - - .

, , , . , .

I also suggest performing the same procedure using docker runinstead docker-composeto cancel the problem with docker-compose

Yours faithfully

+2
source

Restarting the docker also solved the mount problem, thanks!

To restart the docker, use the following command: service docker restart.

This should take a couple of seconds, and the docker should turn on again. If you want to see this, you can run: service docker status.

-1
source

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


All Articles