"plugin ‘bridge’ not found"在使用Docker Compose创建Docker网络时。

huangapple go评论65阅读模式
英文:

"plugin 'bridge' not found" when creating Docker network with docker compose driver bridge

问题

我在尝试创建Docker网络时遇到了错误。我收到的错误消息是:

这个错误似乎与Docker网络配置有关。我在Ubuntu 20上使用Docker,但不确定如何解决这个问题。请问是否有人可以帮助我了解可能导致这个错误的原因以及如何修复它?

附加细节

Docker版本:Docker版本20.10.17,构建100c701
操作系统:20.04

docker-compose:

version: "3.8"
services:
  db:
    build: ./database/
    ports:
      - 5432:5432
    volumes:
      - ./database/create_fixtures.sql:/docker-entrypoint-initdb.d/create_fixtures.sql
    networks:
      network:
        ipv4_address: 172.20.0.3

  pgadmin:
    image: dpage/pgadmin4
    environment:
      - PGADMIN_DEFAULT_EMAIL=admin@admin.com
      - PGADMIN_DEFAULT_PASSWORD=root
    ports:
      - "5050:80"
    networks:
      network:
        ipv4_address: 172.20.0.2

  app:
    build: ./app/
    networks:
      network:
    depends_on:
      - db
networks:
  network:
    ipam:
      driver: bridge
      config:
        - subnet: "172.20.0.0/16"
          gateway: "172.20.0.1"

我已经尝试了以下步骤:

  • 重新启动Docker:我重新启动了Docker服务并重新启动了计算机,但问题仍然存在。

  • 检查Docker网络插件

  • 验证Docker配置:我检查了Docker守护程序配置文件(在Linux上是/etc/docker/daemon.json),但它不存在,我从未创建过。

尽管尝试了这些步骤,问题仍然存在。我将非常感谢任何关于解决此问题的见解或指导。提前感谢您的帮助!

英文:

I'm encountering an error while trying to create a Docker network. The error message I receive is:
"plugin ‘bridge’ not found"在使用Docker Compose创建Docker网络时。

This error seems to be related to the Docker networking configuration. I'm using Docker on Ubuntu 20 I think, and I'm not sure how to resolve this issue. Can someone please help me understand what might be causing this error and how I can fix it?

Additional Details:

Docker version: Docker version 20.10.17, build 100c701
Operating system: 20.04

docker-compose:

version: "3.8"
services:
  db :
    build : ./database/
    ports :
      - 5432:5432
    volumes:
      - ./database/create_fixtures.sql:/docker-entrypoint-initdb.d/create_fixtures.sql
    networks:
        network:
              ipv4_address : 172.20.0.3
      
  pgadmin:
        image: dpage/pgadmin4
        environment:
            - PGADMIN_DEFAULT_EMAIL=admin@admin.com
            - PGADMIN_DEFAULT_PASSWORD=root
        ports:
            - "5050:80"
        networks:
            network:
              ipv4_address : 172.20.0.2

  app :
    build: ./app/
    networks:
        network:
    depends_on : 
      - db
networks:
  network:
    ipam:
      driver: bridge
      config:
        - subnet : "172.20.0.0/16"
          gateway: "172.20.0.1"

I have already tried the following steps:

  • Restarting Docker: I restarted the Docker service and also rebooted
    my computer, but the issue persists.
  • Checking Docker Networking Plugins:

"plugin ‘bridge’ not found"在使用Docker Compose创建Docker网络时。

  • Verifying Docker Configuration: I checked the
    Docker daemon configuration file (/etc/docker/daemon.json on Linux) and It doesn't exist i never created one

    present. Despite these attempts, the problem remains. I would
    appreciate any insights or guidance on resolving this issue. Thank
    you in advance for your help!

Despite these attempts, the problem remains. I would appreciate any insights or guidance on resolving this issue. Thank you in advance for your help!

答案1

得分: 1

删除整个文件中的所有networks:块。

你展示了很多Docker自动执行的手动设置。如果没有声明networks:,Compose会创建一个名为default的网络并将所有容器附加到它。然后Docker会自动分配IP地址给容器,并提供一个DNS系统,可以将容器名称解析为这些IP地址。

这意味着你几乎不需要担心容器内部的IP地址。它们无法从Docker外部访问(除非在一个非常特定的Docker主机设置中),在Docker内部,你可以使用Compose服务名称作为主机名。例如,你可以在app容器上设置一个环境变量PGHOST=db,它将解析为数据库容器。

在你的问题和其他答案中,你暗示了手动指定网络driver:可能会出现问题。在非Swarm模式下,bridge驱动程序应该是默认模式,你不需要明确指定它。

Docker文档中的Compose网络中有关于自动设置的更多细节,以及如果绝对需要的话如何覆盖default网络配置的信息。

英文:

Delete all of the networks: blocks in the entire file.

You've shown a lot of manual setup here that Docker does automatically. If you have no networks: declared, Compose creates a network named default and attaches all of the containers to it. Docker then automatically assigns IP addresses to containers, and provides a DNS system that can resolve the container names to those IP addresses.

This means you almost never need to worry about the container-internal IP addresses at all. They're not reachable from outside Docker (except on one very specific Docker host setup), and within Docker you can use the Compose service names as host names. For example, you could set an environment variable PGHOST=db on the app container, and that will resolve to the database container.

In your question and other answer you hint at problems manually specifying the network driver:. In non-Swarm mode, the bridge driver should be the default mode and you don't need to specify that explicitly.

Networking in Compose in the Docker documentation has more details about what gets set up automatically, and how to override the default network configuration if you absolutely need to.

答案2

得分: 0

我通过简单地从Docker Compose文件中移除了"driver: bridge"来修复它。

英文:

I fixed it by simply removing driver: bridge from the docker compose file

huangapple
  • 本文由 发表于 2023年6月9日 08:19:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76436451.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定