iamdork / compose

Command line replacement for docker-compose, adding dork magics.
MIT License
2 stars 2 forks source link

Subnet plugin #55

Closed sepal closed 7 years ago

sepal commented 7 years ago

Currently docker manages networks by itself, if no subnet is passed when creating networks. The default subnets are 172.[17-31].0.0/16 and 192.168.[0-240].0/20, which means the amounts of subnets and therefore applications you can up on single node is limited to about 32. This is a very small number, especially on dev servers, where multiple people work on a lot of different sites and also for our demo server. There are efforts to allow to define a default pool of networks for the docker daemon, see moby/moby#29376, but due to incompatibilities with the overlay network used for swarm, it seems unlikely that this feature will be implemented soon. This PR therefore tries to implement a plugin, which will allow to set a default network pool and inject the subnet config into the services.

sepal commented 7 years ago

So the basic functionality is done. Just add the subnet plugin to your DORK_PLUGINS variable and optionally set the DORK_SUBNET_DEFAULT variable to a start network you would like to use. By default it is set to DORK_SUBNET_DEFAULT='172.20.0.0/24'.

The algorithm to find a free network is pretty dumb and probably will hang or break if you got a lot of projects running. It also would probably be better to somehow define the range of your network pool with a syntax like this: 172.[17-31].0.0/24, but at least the plugin works with existing projects, i.e. it will not fail if you created projects before adding the subnet plugin.

pmelab commented 7 years ago

Nice! Thanks a lot! If finding the next free network really becomes a problem we still can improve it.