大网数据广告活动
服务器运维问答

Docker-Compose in Development - Managing Subnets

· 52CE 我爱测

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 "do…

问题原文

原帖链接 · Schodemeiss · CC BY-SA 3.0

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

已采纳解答

原帖链接 · LeartS · CC BY-SA 4.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。