Compose: Allow to specify subnet with docker-compose --x-networking

Created on 28 Dec 2015  路  7Comments  路  Source: docker/compose

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

arenetworking duplicate

Most helpful comment

All 7 comments

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)

Excellent, this works perfectly. Thank you for pointing that out!

Does not work in version 3.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DhairyashilBhosale picture DhairyashilBhosale  路  3Comments

maltefiala picture maltefiala  路  3Comments

dimsav picture dimsav  路  3Comments

29e7e280-0d1c-4bba-98fe-f7cd3ca7500a picture 29e7e280-0d1c-4bba-98fe-f7cd3ca7500a  路  3Comments

saulshanabrook picture saulshanabrook  路  3Comments