【问题标题】:Invalid address. It does not belong to any of this network's subnets无效地址。它不属于此网络的任何子网
【发布时间】:2021-10-05 15:43:27
【问题描述】:

每当我跑步时:

     docker-compose -f net.yaml up -d

我收到以下错误:

     Creating network "twisted_static-network" with the default driver.
     Creating server ... error

     ERROR: for server  Cannot start service tcp_server: Invalid address 192.168.1.1: It 
     does not belong to any of this network's subnets

     ERROR: for tcp_server  Cannot start service tcp_server: Invalid address 
     192.168.1.1: It does not belong to any of this network's subnets
     ERROR: Encountered errors while bringing up the project.

我试过了:

  1. prune docker 网络,
  2. 删除并重新安装 docker,
  3. 更改了 ipv4 地址。

但问题永远不会改变。

net.yaml

    version: '3'

    services:
      tcp_server:
        image: twisted_tcp:1.0
        container_name: server
        environment:
          - LOCAL_IP=192.168.1.1
        ports:
          - 5679:5678
        privileged: true
        volumes:
          - ./twisted_server.py:/run/twisted_server.py 
        command: >
            bash -c pip3 install twisted
            && "python3 twisted_server.py"
        networks:
          static-network:
            ipv4_address: 192.168.1.1

      tcp_client:
        image: twisted_tcp:1.0    
        depends_on:
          - tcp_server
        container_name: client
        environment:
          - LOCAL_IP=192.168.1.2
        ports:
          - 5680:5678
        privileged: true
        volumes:
          - ./twisted_client.py:/run/twisted_client.py
        command: >
          bash -c pip3 install twisted
                  && "python3 twisted_client.py"
        networks:
          static-network:
            ipv4_address: 192.168.1.2


    networks:
      static-network:
        ipam:
          config:
            - subnet: 192.168.0.0/24
              gateway: 192.168.0.1

【问题讨论】:

    标签: docker docker-compose ipv4 subnet


    【解决方案1】:

    解决了!

    问题最终成为net.yaml 中的-subnet

    1. 我改变了这个:-subnet: 192.168.0.0/24
    2. 对此:-subnet: 192.168.0.0/16

    然后就可以了!

    【讨论】:

      【解决方案2】:

      它也应该适用于 192.168.1.0/24。问题是配置中的 IP 分配超出了子网范围。

      【讨论】:

        猜你喜欢
        • 2011-07-26
        • 1970-01-01
        • 2012-09-21
        • 1970-01-01
        • 2018-02-12
        • 2019-12-08
        • 2014-05-30
        • 2018-08-16
        • 2013-05-21
        相关资源
        最近更新 更多