Docker make up v3: the difference between mounting a volume type and binding

I use version docker-compose3 syntax and want to use some volumes. The long syntax documentation for volumes reads as follows:

type: mount type volumeorbind

but does not fully explain the difference. What is it?

+6
source share
1 answer

bindis easier to understand. It takes a host path, say, /dataand mounts it inside your container, say /opt/app/data. /datacan be any, possibly installed on NFSor, possibly, a local host. docker run -v /data:/opt/app/data -d nginx

volume mount is where you can use a named volume.

, , :

docker volume create data docker run -d -v data:/opt/app/data nginx

, : docker run -d -v /opt/app/data nginx

docker volume ls, docker .

docker-compose , :

web:
  image: nginx:latest
  volumes:
    /data:/opt/app/data
    data:/opt/app/data1

volumes:
  data:
+9

All Articles