我正在尝试在 MacBook 上复制生产环境 (CentOS 7),该环境基本上由几个与几个数据库交互的 docker swarm 服务组成。这些数据库位于连接到服务的同一覆盖网络的容器中,但不在 swarm 中。
我在 MacBook 中创建了 Swarm 和网络
docker swarm init
docker network create --attachable --driver overlay --subnet 10.0.1.0/24 test-net
我有这个撰写文件来运行其中一个数据库
version: '3.8'
services:
cassandra:
image: cassandra:3.11.4
networks:
test-net:
ipv4_address: 10.0.1.10
networks:
test-net:
external: true
但每当我尝试运行它时,docker-compose up
它都会显示
ERROR: for d129d5ad7ec8_cassandra-test Cannot start service cassandra: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded
ERROR: for cassandra Cannot start service cassandra: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded
ERROR: Encountered errors while bringing up the project.
或者
ERROR: for d129d5ad7ec8_cassandra-test Cannot start service cassandra: network test-net not found
ERROR: for cassandra Cannot start service cassandra: network test-net not found
ERROR: Encountered errors while bringing up the project.
docker network inspect test-net
看起来完全正常,与生产环境一致,我还没有通过浏览类似问题找到可行的解决方案。我也尝试运行没有 Compose 文件的容器,结果类似。为什么我无法将此容器附加到覆盖网络?