Search code examples
docker-compose

No services in docker-compose are configured to start at boot but some always do


I have two development environments that regularly run projects that use docker-compose. I always gracefully stop the docker-compose process before shutting down the system. One laptop has suddenly begun automatically starting a particular container under a particular docker-compose configuration at boot-up. The other system starts like ten containers (a couple of containers in like five different docker-compose configurations), and has been doing this for a year.

All docker-compose services are configured with either no or unless-stopped.

Can anyone explain this behavior?


Solution

  • It appears that dirty Docker or docker-compose state might be involved here. When this started happening on a second system, I tried running 'docker compose down' (which destroys the containers) on that system, and the problem went away. I haven't yet had the chance to try this on the original system. Seems like this resolves it, though.

    Edit: Yes, this appears to solve the problem. Breaking out of the docker-compose session leaves things unclean. If you then do an additional down, you'll see that it then properly stops things. Running it once more after this is then a true no-op (no action is taken). Using down, in general, mitigates the issue, but properly stopping docker-compose seems to avoid the issue entirely. If you still want to use CTRL+C to break out of it (as I do from instinct), you can still follow-up later or before a reboot with a proper down.