在具有桥接网络的VM中无法访问Docker网络

问题描述

我在Ubuntu PC的默认网络上运行了两个docker容器。而且我有一个通过桥接适配器(wlp3s0)在同一台PC上运行的Ubuntu VM,并且我试图在PC的默认docker网络上再运行2个容器。

PC中的docker_compose.yml文件:

test/docker_compose.yml

version: "3.4"
services:
  container_1:
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - "5000:5000"
    expose:
      - "5000"

  container_2:
    build:
      context: .
      dockerfile: ./2/Dockerfile
    ports:
      - "5001:5001"
    expose:
      - "5001"

networks:
  default:
    driver: bridge

VM中的docker_compose.yml文件:

test/docker_compose.yml

version: "3.4"
services:
  container_1:
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - "5000:5000"
    expose:
      - "5000"

  container_2:
    build:
      context: .
      dockerfile: ./2/Dockerfile
    ports:
      - "5001:5001"
    expose:
      - "5001"

networks:
  default:
    external:
      name: test_default

docker network list在PC中产生以下结果:

NETWORK ID          NAME                DRIVER              SCOPE
e3c3a779e67a        bridge              bridge              local
6ffc94e5474c        host                host                local
3a177ebcdaae        none                null                local
40ea39edee9a        test_default        bridge              local

docker network list在VM中产生以下结果:

NETWORK ID          NAME                DRIVER              SCOPE
e3c3a779e67a        bridge              bridge              local
6ffc94e5474c        host                host                local
3a177ebcdaae        none                null                local

如上所述,我无法连接到VM中的test_default网络。我在哪里做错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...