Created
September 26, 2018 14:31
-
-
Save natcl/3d881d00a56c8a961e6dab8ba51a5a37 to your computer and use it in GitHub Desktop.
docker-compose static IP example
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' | |
networks: | |
mynetwork: | |
ipam: | |
config: | |
- subnet: 172.20.0.0/24 | |
services: | |
nodered1: | |
image: nodered/node-red-docker | |
ports: | |
- "1880:1880" | |
restart: always | |
environment: | |
- TZ | |
- IP_BROKER=mqtt | |
- DOCKER=true | |
- PORT=1880 | |
hostname: nodered1 | |
networks: | |
mynetwork: | |
ipv4_address: 172.20.0.6 | |
nodered2: | |
image: nodered/node-red-docker | |
ports: | |
- "1881:1880" | |
restart: always | |
environment: | |
- TZ | |
- IP_BROKER=mqtt | |
- DOCKER=true | |
- PORT=1880 | |
hostname: nodered2 | |
networks: | |
mynetwork: | |
ipv4_address: 172.20.0.7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works great. It is a good way to use Docker Compose for Static/fixed IP . An alternative option would be to use container names instead of IP Addresses.
My container network has Nginx Reverse Proxy Manager with IP address 10, Portainer Docker Compose with IP Address 11, and finally WorPress MYSQL Docker Compose with IP Address 9 and 8 respectively.