Docker Tip #64: Dealing with Unexplained Docker Errors
Sometimes you'll get weird errors from Docker or your application but you're sure things are set up right. Here's what you can do.
I can’t count the number of times where someone reported an issue on one of my Docker related courses where they mentioned that something went wrong, but then out of the blue they will message me 20 minutes later saying never mind, it’s all good, and all that changed was they restarted Docker.
It’s almost always related to Docker for Windows, Docker for Mac or Docker Machine (vbox).
Here’s my goto checklist for solving unexplainable Docker errors:
docker-compose down && docker-compose up --build
docker-compose down -v && docker-compose up --build
- Restart your Docker daemon
- Reboot your computer (but before doing this, always do #3 first)
- Upgrade to the latest stable Docker / Docker Compose release
The first one will clear out any stopped containers and re-up / build your project. The second one does the same thing but it also removes any associated volumes.
I find myself having to restart Docker for Windows about once a month to get around unexplainable errors. I don’t think Hyper-V handles things too well if you constantly push the maximum resource constraints of its VM.
Typically doing the first 3 things will solve nearly every unexplainable problem but I’ve also seen some issues require a full blown system reboot to get resolved. I’ve also witnessed cases where rebooting the system didn’t fix it, but restarting Docker did. Yay for lots of moving parts!
Upgrading to the latest stable Docker / Compose release is also a good idea, especially if you’re running a much older version of Docker. There are usually dozens of bug fixes per release.