Reputation: 194
Having a simple problem with docker compose down
that I've already researched, but can't find a solution for. Any guidance is appreciated.
docker compose up
works fine, but when I try to down the project, one container won't shutdown / remove. This causes an error while removing network: ... has active endpoints
error during docker compose down.
Here's how I start the containers:
yarn docker:compose:test:up
, which runs "docker compose -f docker-compose.test.yml up"
. Everything starts fine, and life goes on.
Here's the entire docker-compose.test.yml
file:
---
services:
redis:
networks:
- redis-network
command:
- redis-server
- "--appendonly"
- "yes"
- "--requirepass ${REDIS_PASSWORD}"
image: redis
container_name: resonate-redis
restart: always
expose:
- 6379
ports:
- "${REDIS_PORT}:6379"
api:
networks:
- api-network
- redis-network
build: .
command: /bin/sh -c "yarn && yarn migrate:test && yarn start:dev"
container_name: resonate-api
environment:
- NODE_ENV=test
depends_on:
- redis
- pgsql-test
ports:
- "4000:4000"
restart: always
volumes:
- ./:/var/www/api
- ./data/media/incoming:/data/media/incoming
- ./data/media/audio:/data/media/audio
- ./data/media/images:/data/media/images
pgsql-test:
image: postgres:14-alpine
env_file:
- .env
volumes:
- ./data/pgsql-test:/var/lib/postgresql/data
- ./data/pgsql-test-backups:/backups
container_name: resonate-pgsql-test
networks:
- api-network
ports:
- '${POSTGRES_TEST_LOCAL_MACHINE_PORT}:5432'
nginx:
restart: always
container_name: resonate-nginx
networks:
- api-network
build:
context: ./nginx
ports:
- "${NGINX_PORT}:80"
networks:
api-network:
driver: bridge
# app-network:
# driver: bridge
redis-network:
driver: bridge
volumes:
certbot-etc:
certbot-var:
htpasswd:
driver: local
driver_opts:
type: none
device: "${PWD}/htpasswd/"
o: bind
web-root:
driver: local
driver_opts:
type: none
device: "${PWD}/public/"
o: bind
dhparam:
driver: local
driver_opts:
type: none
device: "${PWD}/dhparam/"
o: bind
version: "3.7"
Later, I run docker compose down
and end up with this output:
(base) iMac:api imac$ docker compose down
[+] Running 4/5
⠿ Container resonate-nginx Removed 0.3s
⠿ Container resonate-api Removed 0.5s
⠿ Container resonate-redis Removed 0.3s
⠿ Network api_redis-network Removed 0.1s
⠿ Network api_api-network Error 0.0s
failed to remove network api_api-network: Error response from daemon: error while removing network: network api_api-network id ... has active endpoints
The pgsql-test
container is not removed, and the network can't stop because of this.
I have no idea why this is happening, or what to do in order to fix it. Any help is appreciated.
Thanks!
Upvotes: 5
Views: 8986
Reputation: 91
Just had this happen to me.
failed to remove network ots_djangoapp: Error response from daemon: error while removing network: network ots_djangoapp id 1450efd2df6c has active endpoints
Had been working for years, but it looks as though one of the updates changed things. Possibly in the 2.7.0 bug fixes https://docs.docker.com/compose/profiles/
My yml config utilized profiles
https://docs.docker.com/compose/profiles/
Which I would start with docker-compose --profile prod up -d
and docker-compose down
respectively.
I got it working again by simply adding the explicit --profile argument to the down command.
docker-compose --profile prod down
-cheers
Upvotes: 8