compose: docker-compose up fails if network attached to container is removed
Container start fails, because network it was attached to has been removed. For some reason docker-compose tries to remove that container attached network first, which results with an error.
Steps to reproduce:
docker-compose up
docker network rm dockercomposenetworkrmfails_default
docker-compose up
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 14
- Comments: 15
Thanks for the report! I think there are several things to note here:
docker-compose down
). Outside of this particular problem, it will certainly lead to a slew of other issues down the line.--force-recreate
flag.It would be nice to have some “recreate if necessary” flag. I.e we want to ensure
docker-compose up
does whatever it takes to bring the environment up and if that means it needs to create a network then so be it!--force-recreate
fixed my problem, but it’s strange that the network reference persisted even after usingdown
.My 2 cents: of course it is an issue with docker-compose. When there is no container it will be created by default. When there is no image it will be built by default. When there is no network it will fail. That feels wrong for a tool that helps managing docker containers, images, networks and volumes.
From compose help:
I strongly disagree @shin- that you should know what you can and can not do with containers, images, networks and volumes managed from a docker-compose file. In worst case you are working together on one host and don’t know where the compose file is that created one of the things that you see with
docker
.I’d second the suggestion from @dazinator for a “recreate if necessary” flag. I ran a
docker network prune
command just like @adambro, and since I run several different Docker setups for different projects, I didn’t realize that pruning while working on one large project was going to negatively affect the others. (My fault for not reading and thinking through the warning fromnetwork prune
more when I did so.) But a flag like that would be a nice way of getting a project back on its feet quickly.I had a similar problem. caused by trying to create botfront projects in two separate directories, completely borked the project.
I did:
and was able to get started again.
FYI If you use the docker dashboard to start/stop/restart the project from the image is a good idea.
you can also see the sub-services there too.
Thanks for detailed explanation. Indeed, it happened because I’ve run
docker network prune
some time before.What I don’t get still is why it tries to remove Network that does not exist any more? I guess that caused “not found” error. I haven’t found any other instance of such error message.