Skip to content
FLAVIO COPES
flaviocopes.com
2026

What to do if a Docker container immediately exits

By Flavio Copes

Learn what to do when a Docker container immediately exits on start: run docker logs to read the error, then remove the container and rebuild the image.

~~~

If you run a container using docker run and it immediately exits and every time you press the Start button in Docker Desktop it exits again, there is a problem.

Docker Desktop showing containers with START buttons, indicating they immediately exit after running

The way to figure out what is wrong is to run docker logs, adding the name of the container at the end:

Terminal showing docker logs node-app command output with repeated node not found errors

You can also click the Container name in Docker Desktop, and it will show a list of logs:

Docker Desktop container logs panel showing the same node not found error messages

In this case after a quick Google search I realized I used a single quote in my CMD command.

Note that to fix problems like this, you need to remove the container, but also delete the image and rebuild it.

Tagged: Docker ยท All topics
~~~

Related posts about docker: