120 words
1 minutes
Playing with Docker Logs after Container is Exited
First, run this command in your terminal:
docker ps
There will be no output if no containers are running. Next, run this:
docker ps -a
This will show all containers, including stopped ones. You should see something like this:
| Container ID | Image | Status |
| :------------: | :----------:| :--------: |
| 48bab7f673b3 | hello-world | Exited |
Take note of the container ID because you’ll need it for the next step.
Now, replace the ID in the command below with your container’s ID and run it:
docker logs 48bab7f673b3
This command shows the same output as when you first ran the container. In real-world scenarios, you’ll use this to check the output of running containers like web servers or other services running in the background.
Playing with Docker Logs after Container is Exited
https://rabisiddique.com/posts/docker-logs/Author
Rabi Siddique
Published at
2024-09-10