title: Docker-compose shared volume between containers but that has a path in host
body: <p>I found that you can use named volumes so two containers can exchange data between them. However, I need to store this names volume in my host computer (the computer which is running the docker images). </p>
  
  <p>So how do I create a voluma that is stored in /media/my_volume that is also shared between containers? I tried to simply binding /media/my_volume to both containers but it ended up in everything being erased when I started the compose again</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>version: '3'
  
  services:
    transmission:
      build: ./rpi-transmission
      image: rpi-transmission
      ports:
       - "9091:9091"
       - "51413:51413"
       - "51413:51413/udp"
      volumes:
       - "/home/pi/transmission:/etc/transmission"
       - "/media/external:/home/downloads"
       - "/home/transmission-watch:/home/transmission-watch"
    samba:
      build: ./rpi-samba
      image: rpi-samba
      stdin_open: true
      volumes:
       - "/media/external:/data/share:ro"
    kodi:
      build: ./kodi-rpi
      image: kodi-rpi
      ports:
       - "127.0.0.1:8080:8080"
       - "127.0.0.1:9777:9777/udp"
      devices:
       - "/dev/tty0:/dev/tty0"
       - "/dev/tty2:/dev/tty2"
       - "/dev/fb0:/dev/fb0"
       - "/dev/input:/dev/input"
       - "/dev/snd:/dev/snd"
       - "/dev/vchiq:/dev/vchiq"
      volumes:
       - "/var/run/dbus:/var/run/dbus"
       - "/etc/localtime:/etc/localtime:ro"
       - "/etc/timezone:/etc/timezone:ro"
       - "/home/pi/kodi-rpi/config:/config/kodi"
       - "/home/pi/kodi-rpi/data:/data"
  </code></pre>
  
  <p>I need to use /media/external on both containers. If I give it a name, I can't mount it to /media/external. If I simply do as it it now, I think samba erases the content of transmission</p>