Why do my Docker containers keep persisting after doing a docker-compose down?

0
56
Asked By CuriousCat123 On

Hey folks! I'm pretty new to Docker and I'm running into a weird issue that I can't seem to figure out. I'm using Docker Desktop on Windows with WSL2 for my project setup. I run `docker-compose --build up` to start my containers for the first time, and everything seems fine initially. However, after restarting my computer a few times, I noticed that my database seems to disappear in Adminer, but when I exec into the DB container, the records are still there. After using `docker-compose down` and then `docker-compose up`, my containers come back but the same issue happens. When I insert records via Adminer, they show up, but the data isn't actually saved in the database when I check through exec. Using `docker-compose down -v` removes the containers from Docker desktop and `docker ps -a`, but I can still make API calls to my backend and Adminer just fine, even though the containers don't show. Last time, I spent hours trying to figure this out and suspected I had somehow messed with a process related to my Docker containers. I've even included my `docker-compose.yml` for reference. What could be going wrong?

3 Answers

Answered By PragmaticDev On

If all else fails, double-check the outputs of `wsl --status` and `docker info`. Sometimes the WSL or Docker setup can have issues that aren't obvious at first glance but can affect how containers behave.

CuriousCat123 -

I didn’t think of that! I’ll check those commands and report back. Appreciate the suggestion!

Answered By CodeMaster42 On

Your formatting is a bit tough to read, making it hard to spot any issues in your docker-compose.yml. But from what I can see, it looks pretty standard. Just ensure that the volume paths are correctly set—they can sometimes lead to the kind of confusion you’re describing if they’re not pointing to where you think they are.

CuriousCat123 -

I apologize for the formatting. I’ll work on making it clearer next time! Thanks for the tip.

Answered By DockerWhiz99 On

It sounds like you're encountering issues with orphaned containers. Have you tried the `--remove-orphans` flag when bringing your containers up? That can help clear out any lingering containers that might be causing conflicts. Also, make sure to check if you've renamed any containers at any point, as that can also lead to orphaned instances. Just a heads up, be careful when using `docker system prune -a` since it will remove all unused images and containers, which can help free up space but also clean out everything you might need! Good luck!

CuriousCat123 -

I haven’t renamed any containers; I just use the standard commands. I’ll definitely try the `--remove-orphans` flag, thanks!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.