6

I have a project with a docker image whose volume contains contents on start up. Are there any methods to MERGE the contents of both host and container on the volume yet keep the host contents persistent over in the container?

this is my compose.yml

services:
  db:
    image: mysql
    environment:
      MYSQL_DATABASE: ninja
      MYSQL_ROOT_PASSWORD: pwd
  app:
    image: invoiceninja/invoiceninja
    volumes:
      - ./install-wipay.sh:/install-wipay.sh
      - ./composer.json:/var/www/app/composer.json
      # would like to merge and persist this volume
      - ~/Documents/Git/heroku/invoiceninja/app/:/var/www/app
      - ~/Documents/Git/omnipay-wipay/:/var/repo/omnipay-wipay/:ro
      - ./.env:/var/www/app/.env:ro
      - ./storage:/var/www/app/docker-backup-storage:rw
      - ./logo:/var/www/app/docker-backup-public/logo/
    links:
      - db:mysql
    env_file: .env
  web:
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
codedge
  • 4,754
  • 2
  • 22
  • 38
Kendall
  • 5,065
  • 10
  • 45
  • 70
  • You can use ```shared-storage``` some like this ```/directory-host:/directory/container``` where directory-host is the path of your host and directory-container is the path the docker container. – julian salas Jun 10 '17 at 13:30
  • yes @juliansalas but doesn't that overwrite the original contents of the container volume? – Kendall Jun 10 '17 at 13:38
  • @Kendall it does not *overwrite* the original contents, but shadow them. They will re-appear as soon as the volume is removed again; see [the docs](https://docs.docker.com/engine/tutorials/dockervolumes/#creating-and-mounting-a-data-volume-container). I am not aware of a method apart from mounting the files separately. – Qw3ry Jul 24 '17 at 08:51
  • 1
    @Kendall I just discovered the [OverlayFS-driver](https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/). I have not tried it myself, but you might want to give it a shot – Qw3ry Jul 24 '17 at 09:25

0 Answers0