user9351558
user9351558

Reputation: 11

How can i connect the filesystems of two docker containers

so I have a static files (web app) running on container1, and a node js app that's running on container2, I want the node app the have writing access to the static files in container1. how can I achieve this?

what i tried so far :

Upvotes: 0

Views: 456

Answers (2)

yue you
yue you

Reputation: 2264

A way to do it is docker-compose volume

An example configuration yaml file for docker-compose v3 will be as below.

/share in host-os file system will be shared across these 2 containers

version: "3"
services:
  webapp:
    image: webapp:1.0
    volumes:
      - /share:/share
  nodeapp:
    image: nodeapp:1.0
    volumes:
      - /share:/share

Upvotes: 1

Parth Shah
Parth Shah

Reputation: 1475

Using a simple HTTP server (a simple node one can be found here) on one of the containers will allow you to host the static files. Then, this can be accessed from the other containers using the network all your containers are on.

Another option would be to mount a volume to both your containers. Any changes made via one container would reflect in the other if the same volume is mounted. More info can be found here.

Upvotes: 0

Related Questions