容器重启时 Docker 外部网络影响本地主机网络:ERR_NETWORK_CHANGED

容器重启时 Docker 外部网络影响本地主机网络:ERR_NETWORK_CHANGED

我遇到了一个奇怪的问题docker 网络。我正在使用名为外部网络在启用了自动重启的 Docker 容器中。如果任何容器由于某些错误代码或基础设施相关而重新启动,我将无法访问我的主机网络。

请参阅所附屏幕截图以获得更清晰的说明。

网络错误

我尝试过以下链接,但没有成功。


Dockerfile

FROM node:10.20.1-alpine
RUN apk add --no-cache python make g++
WORKDIR /home/app
COPY package.json package-lock.json* ./
RUN npm install
COPY . .

Docker-Compose

version: "3"
services:
  app:
    container_name: app
    build:
      context: ./
      dockerfile: Dockerfile
    image: 'network_poc:latest'
    ports:
      - 8080:8080
    deploy:
      resources:
        limits:
          memory: 2G
    networks:
      - extenal_network
    restart: always
    command: node index.js

networks:
  shared_network:
    external:
      name: extenal_network

docker 检查 external_network

[
    {
        "Name": "extenal_network",
        "Id": "96476c227ddc14aa23d376392d380b2674fcbad109c90e7436c0cddd5c0a9ac5",
        "Created": "2020-04-14T00:17:10.89980675+05:30",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "7621a2b5a7e460a905bf86c427aea38b6374ac621c0c1a2b9eca4b671aea4dfe": {
                "Name": "app",
                "EndpointID": "04e9d14a17af05eb7a2b478526365cbce7f726a62f5e2cd315244c2639891b1e",
                "MacAddress": "**:**:**:**:**:**",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

任何帮助或建议都将非常感谢。

相关内容