无法与覆盖网络一起使用docker-compose

时间:2019-08-29 00:02:53

标签: docker docker-compose docker-networking

我很困惑这里发生的事情,但是我将其范围缩小到一个很小的测试用例。这是我的docker-compose文件:

version: "3.7"
networks:
    cl_net_overlay:
        driver: overlay
services:
  redis:
    image: "redis:alpine"
    networks:
            - cl_net_overlay

cl_net_overlay网络不存在。当我使用以下命令运行该命令时:

docker-compose up

停顿一会儿,然后说:

WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

Creating network "tmp_cl_net_overlay" with driver "overlay"
Recreating tmp_redis_1 ... error

ERROR: for tmp_redis_1  Cannot start service redis: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded

ERROR: for redis  Cannot start service redis: 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.

在以前的笔记本电脑上,此文件对我来说运行良好。我的docker和docker-compose应该是最新的,因为这是一台全新的笔记本电脑。我缺少一些难题吗?

05:01:11::mlissner@gabbro::/tmp 
↪ docker --version
Docker version 19.03.1, build 74b1e89
05:01:57::mlissner@gabbro::/tmp 
↪ docker-compose --version
docker-compose version 1.24.1, build 4667896b

有什么想法吗?我一直在努力使其整天都能正常工作,但我感觉有点迷失自我。


小跟进。消息说:

  

确保您的网络选项正确,并检查管理器日志

我不知道如何检查经理日志。那可能是有用的第一步?


根据评论进行另一跟进。如果我尝试部署它,我将没有日志,也无法启动:

05:44:32::mlissner@gabbro::~/Programming/courtlistener/docker/courtlistener 
↪ docker stack deploy --compose-file /tmp/docker-compose.yml test2
Creating network test2_cl_net_overlay2
Creating service test2_redis

05:44:50::mlissner@gabbro::~/Programming/courtlistener/docker/courtlistener 
↪ docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE                                        PORTS
5y7o01o5mifn        test2_redis          replicated          0/1                 redis:alpine   

05:44:57::mlissner@gabbro::~/Programming/courtlistener/docker/courtlistener 
↪ docker service ps 5y
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE             ERROR                              PORTS
0kbph0ie8qth        test2_redis.1       redis:alpine        gabbro              Ready               Rejected 4 seconds ago    "mkdir /var/lib/docker: read-o…"   
inr81c3r4un7         \_ test2_redis.1   redis:alpine        gabbro              Shutdown            Rejected 9 seconds ago    "mkdir /var/lib/docker: read-o…"   
tl1h6dp90ur2         \_ test2_redis.1   redis:alpine        gabbro              Shutdown            Rejected 14 seconds ago   "mkdir /var/lib/docker: read-o…"   
jacv2yvkspix         \_ test2_redis.1   redis:alpine        gabbro              Shutdown            Rejected 19 seconds ago   "mkdir /var/lib/docker: read-o…"   
7cm6e8snf517         \_ test2_redis.1   redis:alpine        gabbro              Shutdown            Rejected 19 seconds ago   "mkdir /var/lib/docker: read-o…"   

另一个想法:以root身份运行。同样的问题。

1 个答案:

答案 0 :(得分:2)

您是否拥有正确的插件(请在docker info命令中查看更多信息)?

Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay

它适用于:

$ docker swarm init
$ docker-compose up
WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

Creating network "stackoverflow-57701373_cl_net_overlay" with driver "overlay"
Pulling redis (redis:alpine)...
alpine: Pulling from library/redis
9d48c3bd43c5: Pull complete
(...)
redis_1  | 1:M 29 Aug 2019 01:27:31.969 * Ready to accept connection

何时:

$ docker --version
Docker version 19.03.1-ce, build 74b1e89e8a

info

$ docker info
Client:
 Debug Mode: false

Server:
(...)
 Server Version: 19.03.1-ce
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: ff5mogx0ph4pgmwm2zrbhmjb4
  Is Manager: true
  ClusterID: vloixv7g75jflw5i1k81neul1
  Managers: 1
  Nodes: 1
(...)