Docker Community Forums

Share and learn in the Docker community.

Top-level volume with absolute path


(Rares Vernica) #1

In a .yml file, is it possible to have a top-level volume with absolute path? Something like:

services:
  foo:
    volumes:
      - bar:/dir_container
volumes:
  bar:
    - /dir_host

So, I don’t want Docker to create a volume bar, but mount the host directory /dir_host as volume bar. Then, bar will be mounted on the foo service under /dir_container.

I know I can do:

services:
  foo:
    volumes:
      - /dir_host:/dir_container

But I would like to have /dir_host specified once and mounted by multiple services (us bar). Also, I would like to avoid volumes_from since it is phased out.


(Myaser) #2
services:
  foo:
    volumes:
      - bar:/dir_container

volumes:
  bar:
    driver: local
    driver_opts:
      device: /dir_host
      o: bind

(Steven Roose) #3

I can’t seem to find any documentation on the existing driver options for the local driver. What does o stand for? What other options are there for o and what other paramters can be set?