Provide static IP to docker containers via docker-compose 

version: “3.7”
services:
web-server:
build:
dockerfile: php.Dockerfile
context: .
restart: always
volumes:
– “./html/:/var/www/html/”
ports:
– “80:80”
networks:
vpcbr:
ipv4_address: 192.168.1.10
mysql-server:
image: mysql:5.7.32
tty: true
environment:
MYSQL_ROOT_PASSWORD: XXXXX
volumes:
– mysql-data:/var/lib/mysql
networks:
vpcbr:
ipv4_address: 192.168.1.11
volumes:
mysql-data:

networks:
vpcbr:
driver: bridge
ipam:
config:
– subnet: 192.168.1.8/29

Source: Provide static IP to docker containers via docker-compose – Stack Overflow

Provide static IP to docker containers via docker-compose  was last modified: November 30th, 2020 by Jovan Stosic

Leave a Reply