Inspecting Linux Containers (docker ps, logs, exec)
Concept & Overview
Docker encapsulates applications inside isolated Linux cgroups and namespaces (containers). As a DevOps engineer or sysadmin, troubleshooting containerized workloads requires inspecting running containers and executing commands within their namespaces.
- docker ps: Lists running containers, container IDs, images, uptime, and mapped network ports.
- docker logs : Streams standard output and error logs generated by the containerized service.
- docker exec -it : Executes an interactive or diagnostic command directly inside the container namespace.
docker ps to list active containers, fetch service logs with docker logs web-api, and query the health endpoint inside the container using docker exec -it web-api curl localhost:8080/health.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
docker ps | List running containers and port mappings |
docker logs web-api | Inspect container output logs |
docker exec -it web-api curl localhost:8080/health | Execute command inside running container |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○List containers with docker ps
- ○Fetch container logs with docker logs web-api
- ○Execute command inside container with docker exec
Ready to complete Quest 147?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.