Using `docker logs`, `inspect`, and `exec` for troubleshooting.
When running applications in containers, robust tools for inspection and debugging are essential. The first tool in your arsenal should be `docker logs <container_id_or_name>`. This command fetches the logs from a container, displaying the standard output and standard error of its main process. This is invaluable for seeing application output, error messages, and status updates. To get an even deeper look into a container's configuration and state, you can use `docker inspect <container_id_or_name>`. This command returns a detailed JSON object containing a wealth of information, including network settings (like its IP address), volume mounts, environment variables, and more. It's perfect for verifying configurations and troubleshooting complex issues. Sometimes, you need to go inside the container to see what's happening. The `docker exec` command allows you to run a command inside an already running container. The most common use case is to start an interactive shell session, such as `docker exec -it <container_name> bash`. This gives you a command prompt inside the container's isolated environment, allowing you to check files, see running processes, and test network connectivity from within the container itself. These three commands—`logs`, `inspect`, and `exec`—form a powerful toolkit for debugging and managing your containerized applications.