Skip to content

Instantly share code, notes, and snippets.

@castironclay
Last active December 13, 2022 02:29
Show Gist options
  • Save castironclay/bbec22fb2994f15793813ef596bcb447 to your computer and use it in GitHub Desktop.
Save castironclay/bbec22fb2994f15793813ef596bcb447 to your computer and use it in GitHub Desktop.
5 containers split between networks
## .env
IMAGE=debian:buster
## docker-compose.yml
services:
container1:
image: $IMAGE
command: /bin/bash -c "while true; do echo 'alive' && sleep 60; done"
networks:
network1:
ipv4_address: 192.168.10.2
container2:
image: $IMAGE
command: /bin/bash -c "while true; do echo 'alive' && sleep 60; done"
networks:
network1:
ipv4_address: 192.168.10.3
network2:
ipv4_address: 192.168.20.2
container3:
image: $IMAGE
command: /bin/bash -c "while true; do echo 'alive' && sleep 60; done"
networks:
network2:
ipv4_address: 192.168.20.3
network3:
ipv4_address: 192.168.30.2
container4:
image: $IMAGE
command: /bin/bash -c "while true; do echo 'alive' && sleep 60; done"
networks:
network3:
ipv4_address: 192.168.30.3
network4:
ipv4_address: 192.168.40.2
container5:
image: $IMAGE
command: /bin/bash -c "while true; do echo 'alive' && sleep 60; done"
networks:
network4:
ipv4_address: 192.168.40.3
networks:
network1:
driver: bridge
ipam:
driver: default
config:
- subnet: "192.168.10.0/24"
gateway: "192.168.10.1"
network2:
driver: bridge
ipam:
driver: default
config:
- subnet: "192.168.20.0/24"
gateway: "192.168.20.1"
network3:
driver: bridge
ipam:
driver: default
config:
- subnet: "192.168.30.0/24"
gateway: "192.168.30.1"
network4:
driver: bridge
ipam:
driver: default
config:
- subnet: "192.168.40.0/24"
gateway: "192.168.40.1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment