Reputation: 18660
I need to build an stack with PHP-FPM and NodeJS. I don't want to mix both in the same container so I choose Docker Compose. This is how my docker-compose.yml
looks like:
version: '3'
services:
webserver:
build: https://github.com/reypm/php-fpm
args:
INSTALL_COMPOSER: true
dns:
- 8.8.8.8
- 8.8.4.4
volumes:
- ./laravel_node:/var/www/html
nodejs:
image: node:latest
In Docker Compose v3 volumes_from
disappear and the docs here for volumes isn't so clear to me.
How do I mount the VOLUME /var/www/html
on the NodeJS container so I run a command in NodeJS container and the result is present on PHP-FPM container?
I haven seen some examples 1, 2 but this isn't used or at least I couldn't find how to achieve this.
Upvotes: 0
Views: 124
Reputation: 72868
use a named volume.
all you need to do is drop the ./
from the left side of your volume command
volumes:
- laravel_node:/var/www/html
and the same goes into the node image
volumes:
- laravel_node:/wherever/youwant/this/
by exclusing the path information from the left hand side of the volume, docker will create a named volume called "laravel_node". you can mount this volume into multiple containers, re-use that named volume across container instances, etc.
Upvotes: 1