Last active
August 7, 2018 12:54
-
-
Save cblunt/63bea4dd18676cb4e5654e5950defa31 to your computer and use it in GitHub Desktop.
Linking Containers across Multiple Docker Compose Projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.2' | |
networks: | |
default: | |
external: | |
name: my_net # Needs to be manually created using docker network create | |
services: | |
nginx: | |
image: jwilder/nginx-proxy | |
ports: | |
- '80:80' | |
volumes: | |
- /var/run/docker.sock:/tmp/docker.sock:ro | |
db: | |
image: postgres | |
web_one: | |
build: . | |
depends_on: | |
- db | |
- nginx | |
volumes: | |
- .:/app | |
environment: | |
- RAILS_ENV=development | |
- VIRTUAL_HOST=app_one.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.2' | |
networks: | |
default: | |
external: | |
name: my_net # Needs to be manually created using docker network create | |
services: | |
web_two: | |
build: . | |
volumes: | |
- .:/app | |
depends_on: | |
- db | |
- nginx | |
environment: | |
- RAILS_ENV=development | |
- VIRTUAL_HOST=app_two.local | |
# Optionally use a different database on the same postgres container. | |
# - POSTGRES_DB=app_two_development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker network create my_net | |
$ docker-compose -f docker-compose.1.yml run --rm web_one bin/rails db:setup | |
$ docker-compose -f docker-compose.1.yml -f docker-compose.2.yml up -d | |
$ open http://app_one.local http://app_two.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment