0

I have the following yaml

version: '2'

services:
  database:
    image: sameersbn/mysql
    container_name: invoiceplane_mysql
    volumes:
      - /srv/docker/invoicePlane/mysql:/var/lib/mysql/
    environment:
      - DB_PASS=password
      - DB_USER=root
      - DB_NAME=invoiceplane
      - DB_REMOTE_ROOT_NAME=root
      - DB_REMOTE_ROOT_PASS=password
      - DB_REMOTE_ROOT_HOST=172.18.0.%
    ports:
      - "3306:3306"
    #entrypoint: [/bin/bash, /usr/bin/mysql]
    #entrypoint: mysql -h localhost -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.18.0.%' IDENTIFIED BY 'password'"
  invoiceplane:
    #image: coelis/invoiceplane
    build: ./invoiceplane
    entrypoint: ['/start.sh']
    ports :
      - "10180:80"
    volumes:
      - /srv/docker/invoicePlane/uploads:/var/www/html/uploads
    volumes_from:
      - invoiceplane-wipay
    depends_on:
      - database
      - invoiceplane-wipay
    links:
      - database:mysql
    environment:
      - MYSQL_PORT_3306_TCP_ADDR=172.18.0.2
      - MYSQL_ENV_MYSQL_ROOT_PASSWORD=password
  phpmyadmin:
     image: phpmyadmin/phpmyadmin
     ports :
       - "10181:80"
     environment:
       - MYSQL_USERNAME=root
       - MYSQL_PASSWORD=password
     links:
       - database:db
     depends_on:
       - database
  invoiceplane-wipay:
    build: ./php
    entrypoint: /bin/bash
    command: -c 'composer install && ./vendor/bin/watcher ./vendor/bin/phpunit ./tests ./src'
    volumes:
        - ~/Documents/Git/wipay_invoiceplane/invoiceplane-wipay:/usr/src/app:rw

I'm trying to map the invoiceplane-wipay volume to a the invoiceplane volume that should reside at a path /packages/invoiceplane-wipay

I tried adding to the invoice plane service

volumes:
   - invoiceplane-wipay:/package/invoiceplane-wipay

I need to add the volume from the invoiceplane-wipay service to the path /package/invoiceplane-wipay on invoiceplane service

Kendall
  • 247
  • 1
  • 3
  • 13

1 Answers1

1

From your yml:

  ...
  invoiceplane:
    volumes:
      - /srv/docker/invoicePlane/uploads:/var/www/html/uploads
    volumes_from:
      - invoiceplane-wipay
  ...
  invoiceplane-wipay:
    ...
    volumes:
        - ~/Documents/Git/wipay_invoiceplane/invoiceplane-wipay:/usr/src/app:rw

This will mount /usr/src/app from the invoiceplane-wipay container to the invoiceplane container with the same path. If you want to mount this at another location, then you can't use volumes-from, and I don't recommend volumes-from since it's quickly becoming deprecated and you won't find support for this in swarm mode. You would simply include the same volume source in the other section of the yml:

  invoiceplane:
    volumes:
      - /srv/docker/invoicePlane/uploads:/var/www/html/uploads
      - ~/Documents/Git/wipay_invoiceplane/invoiceplane-wipay:/packages/invoiceplane-wipay
BMitch
  • 5,189
  • 1
  • 21
  • 30