docker network_error ai_generated true

Error response from daemon: network 'my_network' not found: network not found

ID: docker/network-not-created-before-service

Also available as: JSON · Markdown · 中文
90%Fix Rate
86%Confidence
1Evidence
2024-04-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Docker 24.0.6 active
Docker 25.0.3 active
Docker 23.0.5 active
Docker Compose 2.24.0 active

Root Cause

A service or container references a Docker network that has not been created yet, often due to misordered docker-compose or manual creation.

generic

中文

服务或容器引用了尚未创建的 Docker 网络,通常由于 docker-compose 或手动创建顺序错误。

Official Documentation

https://docs.docker.com/network/

Workarounds

  1. 90% success Create the network first: 'docker network create my_network', then start the container. For docker-compose, ensure the network is defined in the networks section. Example: networks: my_network: driver: bridge
    Create the network first: 'docker network create my_network', then start the container. For docker-compose, ensure the network is defined in the networks section. Example:
    networks:
      my_network:
        driver: bridge
  2. 95% success If using docker-compose, run 'docker-compose up -d' which automatically creates networks defined in the compose file before starting services.
    If using docker-compose, run 'docker-compose up -d' which automatically creates networks defined in the compose file before starting services.

中文步骤

  1. Create the network first: 'docker network create my_network', then start the container. For docker-compose, ensure the network is defined in the networks section. Example:
    networks:
      my_network:
        driver: bridge
  2. If using docker-compose, run 'docker-compose up -d' which automatically creates networks defined in the compose file before starting services.

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Running 'docker network create my_network' after the container start attempt may cause the container to still fail because it was created before the network was available.

  2. 85% fail

    Using the same network name but with different driver options does not resolve the missing network issue if it hasn't been created.