Someone asked the same question here - the problem is that it relates to version 2
which I am not using. Is it meanwhile possible to define a static subnet and a static IP address for each started container with docker-compose within the docker-compose.yml
file?
Asked
Active
Viewed 1.5k times
5

manifestor
- 2,473
1 Answers
7
Use the following docker-compose.yml
in order to start your containers in a predefined network with static IPv4 addresses:
version: '3.5'
services:
service1:
image: service1:latest
networks:
service1_net:
ipv4_address: 172.22.0.100
networks:
service1_net:
ipam:
driver: default
config:
- subnet: 172.22.0.0/16

manifestor
- 2,473
service1:
but cannot edit and indent, because the changes are only 4 spaces, but S.O. requires edits to be 6 characters at least. — I think thedriver: ...
line should be directly afterservice1_net:
? – KajMagnus Jan 09 '19 at 11:41