compose icon indicating copy to clipboard operation
compose copied to clipboard

Problem with external network (when executing the command docker compose down)

Open maxbur89 opened this issue 3 years ago • 4 comments

Description Problem with external network when executing the command "docker compose down"

Steps to reproduce the issue:

docker compose -f lubimovka_frontend_develop_deploy.yml --env-file /usr/local/src/develop/.github_vars down
[+] Running 0/0
 ⠿ Network develop_swag_network  Error                                                                                                                                                                                                                                     0.0s
 ⠿ Network develop_db_network    Error                                                                                                                                                                                                                                     0.0s
failed to remove network 1bca0c197facf1c42f2762c6a3b3412ab1798a4a7076e0195ce5ab8054bc36a3: Error response from daemon: error while removing network: network develop_swag_network id 1bca0c197facf1c42f2762c6a3b3412ab1798a4a7076e0195ce5ab8054bc36a3 has active endpoints

Network defined as external:

networks:
  develop_swag_network:
    external: true
    name: develop_swag_network

The documentation says that the external network is not deleted. https://docs.docker.com/compose/reference/down/ "Networks and volumes defined as external are never removed."

At the same time, the old version 1.29.2 works fine:

docker-compose -f lubimovka_frontend_develop_deploy.yml --env-file /usr/local/src/develop/.github_vars down
WARNING: Found orphan containers (swag_develop, backend_develop, postgres_develop, migrations_develop) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Network develop_swag_network is external, skipping

lubimovka_frontend_develop_deploy.yml:

version: '3.8'

services:
  frontend_develop:
    image: "${IMAGE_FRONT}:${IMAGE_FRONT_TAG}"
    container_name: frontend_develop
    environment:
      BASE_URL: ${FRONT_BASE_URL}
      API_BASE_URL: ${DEVELOP_API_BASE_URL}
    networks:
      - develop_swag_network
    ports:
      - "3005:3000"
    restart: always
  frontend_test:
    image: "${IMAGE_FRONT}:${IMAGE_FRONT_TAG}"
    container_name: frontend_test
    environment:
      BASE_URL: ${FRONT_BASE_URL}
      API_BASE_URL: ${TEST_API_BASE_URL}
    networks:
      - develop_swag_network
    ports:
      - "3004:3000"
    restart: always

networks:
  develop_swag_network:
    external: true
    name: develop_swag_network

Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker compose version:

Docker Compose version v2.2.3

Output of docker info:

docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
  compose: Docker Compose (Docker Inc., v2.2.3)
  scan: Docker Scan (Docker Inc., v0.12.0)

Server:
 Containers: 4
  Running: 3
  Paused: 0
  Stopped: 1
 Images: 4
 Server Version: 20.10.12
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version: v1.0.2-0-g52b36a2
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-42-generic
 Operating System: Ubuntu 20.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.844GiB
 Name: temp-test-deploy-server-lub
 ID: HWNU:5MTB:36V6:SWPY:LCKV:FJ3J:LC57:35PQ:FP2D:EAQK:SZ3U:VJBQ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

(paste your output here)

Additional environment details:

maxbur89 avatar Feb 04 '22 12:02 maxbur89

Anyone on this? I just tried with the --compatibility flag to get docker-compose v2 to work as v1 did. But, no cigar.

See:

Screenshot 2022-03-10 at 21 24 48

This is on v2.2.3 of Docker-compose


Thank you

larssb avatar Mar 10 '22 20:03 larssb

https://github.com/docker/compose/issues/9172 also likely solves this. So can we close?

larssb avatar Mar 16 '22 18:03 larssb

@larssb Actually, the bug still persists for me. Docker Compose version v2.6.0

EDIT: Also somehow fails with Docker Compose version v2.9.0 :/

InCogNiTo124 avatar Aug 12 '22 19:08 InCogNiTo124

I'm also seeing this with v2.11.0.

Inspecting the network, I see "Internal": false, is set, the compose file has the network declared with external: True as well.

stumpylog avatar Sep 22 '22 17:09 stumpylog

Hi @stumpylog, I'm having trouble replicating this in v2.11.0. Could you share a Compose file that reproduces this, along with how you're creating the external network and any other relevant steps?

laurazard avatar Sep 23 '22 10:09 laurazard

It's only occurring on one Compose file so far, which has information in it I can't share. Attempts to replicate it with a shareable example have failed so far.

Maybe relevant, when I inspect the network in question, I see it has labels, which other created networks do not:

        "Labels": {
            "com.docker.compose.network": "reverse-proxy",
            "com.docker.compose.project": "traefik",
            "com.docker.compose.version": "2.9.0"
        }

It was created a month ago, but I believe it was just docker network create reverse-proxy

stumpylog avatar Sep 23 '22 13:09 stumpylog

Maybe relevant, when I inspect the network in question, I see it has labels, which other created networks do not:

Yup, same here. Seems like Docker Compose added some labels to the network somehow...

        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "traefik",
            "com.docker.compose.version": "2.6.0"
        }

InCogNiTo124 avatar Sep 24 '22 21:09 InCogNiTo124

Such labels indeed will confuse compose as this makes those resources look like they're managed by compose, not external, and could explain this issue. Sounds to me network has been created using some compose up command with a modified compose file, not using docker network create ..., and so resources metadata are incorrect.

ndeloof avatar May 03 '23 12:05 ndeloof

This should have been fixed by https://github.com/docker/compose/pull/10555 If the issue persist after next release (v2.17.4, to be released soon) feel free to comment or create a follow up issue

ndeloof avatar May 14 '23 14:05 ndeloof