# What to do if a Docker container immediately exits

> 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.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-07-15 | Topics: [Docker](https://flaviocopes.com/tags/docker/) | Canonical: https://flaviocopes.com/docker-container-exits/

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](https://flaviocopes.com/images/docker-container-exits/Screen_Shot_2020-07-05_at_12.08.13.png)

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](https://flaviocopes.com/images/docker-container-exits/Screen_Shot_2020-07-05_at_12.09.10.png)

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](https://flaviocopes.com/images/docker-container-exits/Screen_Shot_2020-07-05_at_12.13.48.png)

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.
