4

I'm currently using Docker-Compose for development with a small team of people. I'll describe the setup and scenario we currently are facing.

We have a single project checked into our VCS. Devevelopers check this out and do a "docker-compose up", all on a single host, but in home folders. This creates the default network and automatically assigns a subnet to the new default network (so far, so 'docker-compose'). This is great for us as it isolates the development environments from each other, and allows us to use the named services to access our databases, etc in our Compose files - all without stepping on toes and developers don't need to configure anything manually.

The snag is; this default network has an ever incrementing subnet of 172.*.0.0. This is fine until we reach subnets that are currently in use on our corporate network. For example: our VPN uses 172.19.0.0. We have about 4 or 5 of these subnets that we will create access problems with once we hit them when enough developers fire up the stacks.

How do other people manage this situation for development with Docker Compose?

Essentially, we have many hosts running Docker, with many different applications and many developers on each application. Defining a single subnet in the compose files; per user; per application (to ensure all subnets are unique, regardless of host) would become an absolute nightmare to manage and likely become an exercise in spreadsheet management.

I can't even find a way of enforcing Docker-Compose to use a different subnet range, such as 10.0.0.0 etc - which would be fine on our corporate network.

Any help with this kind of configuration would be appreciated. Surely others use Docker-Compose to create development environments?

Regards

Schodemeiss
  • 230
  • 1
  • 2
  • 7

2 Answers2

1

Docker 18.06 introduces the --default-address-pool option. With it you can specify the address range that user defined networks will use by default if not explicitly set with the --subnet parameter of the network. You can see the pull requests where the features has been implemented and discussed for more information: moby/29376, moby/36054, moby/36396,

--default-addr-pool

This flag specifies default subnet pools for global scope networks. Format example is --default-addr-pool 30.30.0.0/16 --default-addr-pool 40.40.0.0/16

LeartS
  • 76
  • 4
-1

Configuration of docker networking lies not in docker compose, but in daemon configuration itself. What you want to do is to change the default network docker uses, which is done by passing --bip=10.110.0.1/16 (mind the 1 in the end, since you need a valid IP for docker to bind to) in your docker daemon startup script.

Since you haven't provided info about you OS, you can simply try to execute

docker daemon --bip=10.110.0.1/16

to change network to 10.110.0.0/16

On my OpenSuse box i've edited /etc/sysconfig/docker where i've set DOCKER_OPTS="--bip=10.110.0.1/16" to get the same result.

See official documentation for further instructions:

Andrew
  • 228
  • 3
  • 12
  • 1
    Unfortunately this seems to only affect single containers not attached to another network besides the default bridge. The default network that docker compose creates per project is still putting them into 172. – Schodemeiss Apr 16 '17 at 17:12