compose: 1.5.0-rc2: Compose does not remove the network during rm
$ docker-compose --x-networking up -d
Creating network "counter" with driver "bridge"
Creating counter_web_1
Creating counter_mongo_1
$ docker-compose --x-networking stop
Stopping counter_mongo_1 ... done
Stopping counter_web_1 ... done
$ docker-compose --x-networking rm
Going to remove counter_mongo_1, counter_web_1
Are you sure? [yN] y
Removing counter_mongo_1 ... done
Removing counter_web_1 ... done
$ docker network ls
NETWORK ID NAME DRIVER
d84962a207f8 counter bridge
f60408bc3b3b bridge bridge
13a612e10bd7 none null
517effa88694 host host
After, rm
I still have a network created with the project name
I would expect this to be removed
NOTE: This also causes an issue with Swarm that I will raise another issue for
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16
@dnephin
I ran into errors like this:
I had several networks, each for every build left behind on our CI:
I could only create new networks, after deleting old ones.
@dnephin I don’t think putting this in
down
would be the right solutionEngine already has flags in
docker rm
for handling volumes etc…Compose seems to be following this convention
As we create a network per project, I think it’s ok that we delete it too. It’s also safe to do this by default, as there is no risk of losing data (unlike deleting a volume)
Proposal Something like this would work. This would match my expection, that as a user, when I issue a “rm” it removes the containers and the network that was created for the project.
If the users want’s to keep the network around for whatever reason, they can
docker-compose rm -n
@ain
At least for development, you can just remove all networks, like so:
Docker should complain about predefined and in-use networks…
My above-listed problem was eventually unrelated to
docker-compose down
, the removal works:Networks had remained from previous starts, so the question here is if there could be a way to automagically remove redundant networks that are up there for whatever reason, but not used.
I still have this issue.
docker-compose down
does not fix it. I have 31 networks all with unique names. I run compose with a new name that does not match any of the 31 networks but get the “could not find an available predefined network” error. Deleting the excess networks fixes it. I used @nenko-tabakov script that I am just running periodically.It’s fairly reproducible with a CI environment where new builds happen often.
Hey guys, I have the same problem using docker-compose for testing. I ended up with 27 networks before docker-compose failed to start.
Here is a sample script for removing them:
for i in $( docker network ls | grep build | cut -f1 -d ’ ’ ); do docker network rm $i done
Just replace “build” with proper name.