Careeroza
Managing Containers
Listing and Inspecting
Example
docker ps lists running containers; -a includes stopped ones:
docker psExample output
CONTAINER ID IMAGE COMMAND STATUS PORTS NAMES 3f1c9a7e5b2d nginx:1.27 "/docker-entrypoint.…" Up 2 minutes 0.0.0.0:8080->80/tcp web
Everyday Commands
| Command | Does |
|---|---|
docker logs -f web | show (and follow) the container's output |
docker exec -it web sh | open a shell inside a running container |
docker stop web / docker start web | stop / start again |
docker restart web | restart |
docker rm web | delete a stopped container (-f to force) |
docker inspect web | full JSON details: IP, mounts, env, config |
docker stats | live CPU and memory usage |
docker container prune | delete all stopped containers |
Debugging a Container
Example
Read the logs and look inside:
docker logs --tail 3 web
docker exec -it web sh -c "ls /usr/share/nginx/html"Example output
172.17.0.1 - - [07/Oct/2026:10:12:01 +0000] "GET / HTTP/1.1" 200 615 172.17.0.1 - - [07/Oct/2026:10:12:01 +0000] "GET /favicon.ico HTTP/1.1" 404 153 50x.html index.html