compose icon indicating copy to clipboard operation
compose copied to clipboard

How do i set propagation for named volumes?

Open nghianv19940 opened this issue 4 years ago • 5 comments

I want to share files between replicas, other containers and the host, what should i add to this. It's v3.

  database: 
    driver: local 
    driver_opts: 
      o: bind 
      type: bind 
      device:/my/directory

nghianv19940 avatar May 18 '22 09:05 nghianv19940

@nghianv19940

Please take a look at below documentation for docker compose volume :)

https://docs.docker.com/storage/volumes/

maxcleme avatar May 19 '22 07:05 maxcleme

Please take a look at below documentation for docker compose volume :)

It's not at all clear from that page how to define propagation in the top-level volumes key of a ./docker-compose.yml file as in the description, @maxcleme.

rpatterson avatar May 30 '24 13:05 rpatterson

propagation is an option of mount, so this is not to be declared by top-level volume definition, but by mount per services

services:
  test:
    volumes:
    - type: bind
      source: my_volume
      target: /test
      bind:
        propagation: shared

ndeloof avatar May 30 '24 14:05 ndeloof

propagation is an option of mount, so this is not to be declared by top-level volume definition, but by mount per services

Oh! That helps me understand what I was misunderstanding, thanks much!

rpatterson avatar May 30 '24 14:05 rpatterson

propagation is an option of mount, so this is not to be declared by top-level volume definition, but by mount per services

Hmm, that doesn't seem to work. From ./docker-compose.yml:

services:

  foo:
    image: "ubuntu"
    volumes:
      - type: bind
        source: "media_library"
        target: "/media/Library/"
        bind:
          propagation: "shared"
    entrypoint: >-
      sleep 999

volumes:

  media_library:
    name: "media_library"
    driver: "local"
    driver_opts:
      type: "ext4"
      device: "/dev/mapper/_dev_md127p1"

Then I get this error when running the container:

# docker compose run --rm foo
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /media/Crypt/srv/library/media_library

rpatterson avatar May 30 '24 14:05 rpatterson