Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
How do I mount a volume from one container into another one in Compose v3?

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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!