Difficulty: Beginner
How do you troubleshoot a container that starts and immediately exits?
1. **Check Logs**: `docker logs <container_id>` is the first step. 2. **Inspect**: `docker inspect` to see exit codes and status. 3. **Override Command**: Try running with an interactive shell: `docker run -it my-image /bin/sh` to manually test the environment.
# Tailing logs to see issues in real-time
docker logs -f --tail 100 my-app
-f follows the log, --tail 100 shows the last 100 lines.
CLI, Logs, Debugging