首页 > 解决方案 > 如何在 docker compose 中禁用外部网络调用?

问题描述

我正在针对(目前)通过 Internet 对其他服务进行外部网络调用的大型遗留服务运行一组测试。

该项目的目标是将这些外部服务模拟为同一docker-compose网络中的其他 docker 容器。其中一些服务是我们组织运行的微服务,其他服务是第三方供应商。

我们正在记录外部调用以识别该服务正在调用哪些外部端点,并相应地模拟这些调用。但是因为我将把它放在 CI 中,并且这个服务在一个大型组织中有很多贡献者,我想通过将整个docker-compose网络与互联网隔离来强制不调用任何外部服务。

Short of turning off my wifi, How can I disable external calls from these services, while still allowing services in the same docker network to communicate with each other?

The options given here: https://docs.docker.com/network/#network-drivers do not seem to be what I want.

We use CircleCI, so if there is a solution within that configuration thats fine. I just haven't found anything related to that in those docs either, and would prefer a docker-compose solution so I can test it locally.

标签: dockernetworkingdocker-composecircleci

解决方案


推荐阅读