How to Check Docker Containers: Status, Ports, and Resource Usage

Developer using a laptop while managing Docker containers from the command line

Start with docker ps for running containers and docker ps -a for every container. Then use docker inspect, docker port, and docker stats when you need configuration, networking, or resource details.

List running containers

docker ps

Check the STATUS, PORTS, and NAMES columns. A status such as Up 2 minutes means the main process is running.

List all containers

docker ps -a

This includes stopped and exited containers. An Exited (1) status means the process ended with exit code 1; check its logs next.

Inspect container configuration

docker inspect my-container

This prints JSON containing the image, environment, mounts, networks, restart policy, and state. Use it when a container behaves differently from your Compose file or docker run command.

Check published ports

docker port my-container

This shows how container ports map to host ports. If the output is empty, the container may be running without a published host port.

View live CPU and memory usage

docker stats
docker stats --no-stream my-container

The first command continuously streams usage for running containers. The second prints one sample for a specific container. Press Ctrl+C to stop a live stream.

See processes inside a container

docker top my-container

This lists processes visible inside the container. It is useful when the container is running but the expected application process is missing.

Check a Compose application

docker compose ps
docker compose config

Run these from the folder containing the Compose file. ps shows service status; config validates and renders the resolved configuration.

A quick checking routine

  1. Run docker ps -a.
  2. Check logs if the status is Exited.
  3. Check ports with docker port.
  4. Inspect mounts and environment variables with docker inspect.
  5. Check resource pressure with docker stats.

Next steps

For application output, use docker logs. For the official command details, see Docker’s container CLI reference and stats reference.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top