docker 中的错误:网络“路径”声明为外部,但无法找到

gee*_*ekt 56 docker dockerfile docker-compose

我是码头工人的新手。我被分配了一个使用 Docker 容器进行开发的任务。我按照在 Windows 10 上安装 Docker 和容器的教程进行操作,但出现以下错误:network remaxmdcrm_remaxmd-network declared as external, but could not be found

到目前为止我已经完成的步骤是:

  1. 从 GitHub 克隆存储库。
  2. 在我的笔记本电脑上安装了 Docker。
  3. 安装 Docker 后,我进入项目的根目录并运行以下命令。docker-compose build -d -t docker-compose.yml- docker-compose.yml 是根目录中的文件。
  4. 我打开 Docker 应用程序并运行创建的图像。
  5. 我运行了命令docker-compose up。当我运行此命令时,出现我在开头指定的错误。network remaxmdcrm_remaxmd-network declared as external, but could not be found

docker-compose.yml

services:
    ui:
        build:
            context: .
            dockerfile: Dockerfile.development
        volumes:
            - .:/app
        ports:
            - "5000:5000"
        restart: unless-stopped
        networks:
            - remaxmdcrm_remaxmd-network

    redis:
        image: 'redis:alpine'
        networks:
            - remaxmdcrm_remaxmd-network
networks:
    remaxmdcrm_remaxmd-network:
        external: true
Run Code Online (Sandbox Code Playgroud)

然:docker ps -a

ID              IMAGE
5e6cf997487c   remaxmd-site_ui:latest      
451009e0a2a6   redis:alpine                
85e7cde67d05   docmer-compose.yml:latest 

Run Code Online (Sandbox Code Playgroud)

我可能在这里做错了什么。有人可以帮助我吗?我非常感谢您的宝贵时间!

gee*_*ekt 129

我终于解决了这个问题。问题来自于我在 docker-compose.yml 中remaxmdcrm_remaxmd-network声明为外部的事实。安装过程中没有创建外部网络,因此我需要创建一个桥接网络。我运行了命令docker network create "name_of_network"

有关更多详细信息,这里是完整的文档


Pet*_*mau 16

您不必在运行之前运行命令来创建网络docker compose,如果网络不存在,Docker 应该创建网络。您收到此错误的原因是因为您将网络声明为外部网络,这意味着 Docker 期望它已经存在。如果需要新的,请删除external: true


小智 5

您可以查看docker network ls并使用bridge网络