docker工人组成共享卷映射到path

我有以下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 

我试图将invoiceplane-wipay卷映射到应位于path/ packages / invoiceplane-wipay的invoiceplane卷

我试图添加到发票平面服务

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

我需要将invoiceplane-wipay服务的卷添加到invoiceplane服务的path/包/ invoiceplane-wipay

从你的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 

这会将/ usr / src / app从invoiceplane-wipay容器挂载到具有相同path的invoiceplane容器中。 如果你想在另外一个地方安装,那么你不能使用volumes-from ,也不build议使用volumes-from因为它很快就会被弃用,而且你不会在swarm模式下find它的支持。 您只需在yml的其他部分包含相同的音量来源:

  invoiceplane: volumes: - /srv/docker/invoicePlane/uploads:/var/www/html/uploads - ~/Documents/Git/wipay_invoiceplane/invoiceplane-wipay:/packages/invoiceplane-wipay