Reputation: 77
I want to know how to share application folder between container to container. I found out articles about "how to share folder between container and host" but i could not find "container to container".
I want to do edit the code for frontend application on backend so I need to share the folder. <- this is also my goal.
Any solution?
My config is like this
/
- docker-compose.yml
|
- backend application
|
_ Dockerfile
|
-Frontend application
|
- Dockerfile
And docker-compose.yml is like this
version: '3'
services:
railsApp: #<- backend application
build: .
command: bundle exec rails s -p 5000 -b '0.0.0.0'
volumes:
- code_share:/var/web/railsApp
ports:
- "3000:3000"
reactApp: #<- frontend application
build: .
command: yarn start
volumes:
- code_share:/var/web/reactApp
ports:
- "3000:3000"
volumes:
code_share:
Upvotes: 0
Views: 66
Reputation: 110
You are already mounting a named volume in both your frontend and backend now.
According to your configuration, both your application /var/web/railsApp
and /var/web/reactApp
will see the exact same content.
So whenever you write to /var/web/reactApp
in your frontend application container, the changes will also be reflected in the backend /var/web/railsApp
To achieve what you want (having railsApp
and reactApp
under /var/web
), try mounting a folder on host machine into both the container. (make sure your application is writing into respective /var/web
folder correctly.
mkdir -p /var/web/railsApp /var/web/reactApp
then adjust your compose file:
version: '3'
services:
railsApp: #<- backend application
build: .
command: bundle exec rails s -p 5000 -b '0.0.0.0'
volumes:
- /var/web:/var/web
ports:
- "3000:3000"
reactApp: #<- frontend application
build: .
command: yarn start
volumes:
- /var/web:/var/web
ports:
- "3000:3000"
Upvotes: 2