When i use docker-compose --x-networking up it create subnet for each containers group (for each folder with docker-compose.yml) with 172.18.0.0/16, 172.19.0.0/16 .... etc.
In our office network we already have 172.18.. and I can not connect to these machines from containers.
I want to specify subnet when I start containers group with docker-compose --x-networking
This is not something that is controlled by compose. It's up to the docker engine to decide on the subnet.
how can i use specify subnet if i use docker-compose?
Or I should not use it?
I think specifying a subnet might already be supported by docker network create.
It will be supported by compose with the changes in #2478 (#2564)
@dnephin Can you provide examples on how to use this in docker-compose? When I try the following with docker-compose v2 files:
networks:
front-tier:
subnet: 192.170.0.0/16
gateway: 192.170.0.1
back-tier:
subnet: 192.171.0.0/16
gateway: 192.171.0.1
I get an error:
ERROR: Validation failed in file './docker-compose.yml', reason(s):
networks.back-tier value Additional properties are not allowed ('subnet', 'gateway' were unexpected)
networks.front-tier value Additional properties are not allowed ('subnet', 'gateway' were unexpected)
It's under ipam config: https://docs.docker.com/compose/compose-file/#ipam
Excellent, this works perfectly. Thank you for pointing that out!
Does not work in version 3.
Most helpful comment
It's under ipam config: https://docs.docker.com/compose/compose-file/#ipam