How does docker use the host’s volume

  docker, question

Demo address on github

https://github.com/verdaccio/ …

Github articles referenced

https://github.com/moby/moby/ …

Modify my docker-compose as follows

version: '3'
 services:
 verdaccio:
 build: verdaccio-ldap/
 ports:
 - "4873:4873"
 volumes:
 - "verdaccio:/verdaccio"
 ldapserver:
 image: larrycai/openldap:latest
 ports:
 - 389:389
 links:
 - verdaccio
 
 volumes:
 verdaccio:
 driver_opts:
 type: none
 device: ~/Documents/docker/backup/tmp
 o: bind

However, it seems to be invalid. There is still nothing in my local folder. Even I don’t know whether this is a project problem or a docker problem. Solve it

Try this:

volumes:
 
 //Here, the data volume is mounted using an absolute path. The front /opt/data is hosted and the back /var/lib/mysql is inside the container
 //That is to say, the host's /opt/data is implicitly injected into the container's /var/lib/mysql
 - /opt/data:/var/lib/mysql

If not, use itdocker runCreate a container manually and then use the-vParameter specifies the data volume to try and see if it is a problem with the docker environment itself.