skip to Main Content

I’m encountering an error while trying to create a Docker network. The error message I receive is:
enter image description here

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:
            - [email protected]
            - 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:

enter image description here

  • 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!

2

Answers


  1. Chosen as BEST ANSWER

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


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search