15

I'm trying bring down all services for an external network defined in my docker-compose file (using version 2).

When I try to do a docker-compose down, I get a message stating,

Network 'your_network' is external, skipping

Is there a way, using docker-compose, to stop and remove all the containers for a user-defined or external network?

2
  • 2
    That message appears to be about the network, not the containers. Is is actually failing to stop the containers?
    – larsks
    Commented Mar 30, 2016 at 21:01
  • Doing a docker ps still shows them as running.
    – sager89
    Commented Mar 30, 2016 at 21:25

4 Answers 4

5

I've encountered the same error. docker-compose can only stop the containers started by docker-compose. In my case: the containers that I wanted to stop were started by docker run. So I stopped the containers one by one. then started them with the docker-compose.yml

Not sure if you are the same case.

2

This isn't an error. You have a network declared as "external", mostly meaning that it may be used by other services or other docker-compose files. So when you stop those services, the network gets "skipped", because the network is shared among all services that reference it, and it would create an error to try to delete the external network.

0

Docker error messages (and in general) sucks as always.

Originally I had multiple services that used a custom network, as shown here:

version: '3'

networks:
  mynet:
    external: true

services:
  nexus-repository:
    image: sonatype/nexus3
    ports:
      - '8082:8081'
    networks:
      - mynet
    volumes:
      - '/nexus-data:/nexus-data'

To remove the containers I tried:

  • sudo docker-compose down => NOPE
  • ssudo docker network remove mynet => NOPE
  • sudo docker-compose rm -sfv nexus-repository => NOPE

Nothing worked until I completely removed all references to the exernal network.


Solution

services:
  nexus-repository:
    image: sonatype/nexus3
    ports:
      - '8082:8081'
    volumes:
      - '/nexus-data:/nexus-data'

No more:

Network 'mynet' is external, skipping

And no more containers !

2
  • Could you please, which references are you talking about? Where can we find those? Commented Mar 3, 2021 at 11:43
  • @LadenkovVladislav This was 1 year ago so I don't remember much. But of what I can tell while reading my answer is that you should try removing the TWO networks sections from your docker-compose file. If you compare both code snippets you'll see that they are not present in the second one. => Remove the 2 sections, then UP the container, then DOWN and put back the removed sections and then final UP... It should be repaired.
    – Doctor
    Commented Mar 3, 2021 at 16:41
0

In my case, I had started my containers using a docker-compose file indeed yet through VSCode's remote container extension. If that's your case, you can stop your containers using VSCode's Docker extension (right click on your container group -> Docker Compose Down)

Not the answer you're looking for? Browse other questions tagged or ask your own question.