Mike Barkas

Software and DevOps

Mike Barkas

Mike Barkas

Software and DevOps

Customizing Docker ps Output

December 3, 2026

With more than a few containers running, docker ps is hard to read. Every row has eight columns, and the PORTS column alone can be longer than my terminal is wide. Each line wraps and the output becomes a wall of text.

This is frustrating and most of the time I only want to know a few things: the container ID, the image, and the name. Docker lets you choose exactly which columns to show, and you can save that choice as your default.


The --format Option

docker ps takes a --format option with a Go template. Each field goes in double curly braces with a leading dot.

docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Names}}"

CONTAINER ID   IMAGE                    NAMES
5b7e4fa7b0fa   myapp-api                myapp-api-1
23b3f7533a65   pgvector/pgvector:pg17   myapp-db-1

table (this is my favorite part)

The table keyword prints a header row and lines up the columns.

\t puts a tab between columns.

Leave out table and you get the values only, with no header. This is useful for scripts:

docker ps --format "{{.Names}}"

myapp-api-1
myapp-db-1

Finding the Field Names

The column headers in the default output are not the field names. The CONTAINER ID column is {{.ID}}, and the CREATED column is {{.RunningFor}}.

To see every field available, print each container as JSON:

docker ps --format "{{json .}}"

Each key in the output is a field you can use in a template.

There is so much output it is hard to find what you are looking for, so I pipe it through jq to read it: (grep for what you are looking for too)

docker ps --format "{{json .}}" | jq

{
  "Command": "\"uvicorn app.main:ap…\"",
  "CreatedAt": "2026-12-03 14:33:18 -0500 EST",
  "ID": "5b7e4fa7b0fa",
  "Image": "myapp-api",
  "Names": "myapp-api-1",
  "Networks": "myapp_default",
  "Ports": "0.0.0.0:8000->8000/tcp",
  "RunningFor": "About an hour ago",
  "State": "running",
  "Status": "Up About an hour",
  ...
}

To match a field to a column, compare the values. The ID value is the one shown under CONTAINER ID.


Case Matters

Templates are case-sensitive. Use the field names exactly as the JSON shows them. {{.Id}} is an error:

docker ps --format "{{.Id}}"

failed to execute template: template: :1:2: executing "" at <.Id>:
cannot evaluate field Id in type *formatter.ContainerContext

Make It the Default

This is the part I didn’t know about. Docker’s client config file, ~/.docker/config.json, has a psFormat key. Whatever template you put there is what plain docker ps uses.

{
  "psFormat": "table {{.ID}}\t{{.Image}}\t{{.Names}}"
}

The file may already have other settings, such as auths or currentContext. Add the key next to them; don’t replace the file.

Now docker ps with no options prints the short version:

docker ps

CONTAINER ID   IMAGE                    NAMES
5b7e4fa7b0fa   myapp-api                myapp-api-1
23b3f7533a65   pgvector/pgvector:pg17   myapp-db-1

Setting a default doesn’t hide anything. A --format on the command line still wins over the config file, so the other columns are one option away:

docker ps --format "table {{.Names}}\t{{.Status}}"

NAMES         STATUS
myapp-api-1   Up About an hour
myapp-db-1    Up About an hour (healthy)

Other Commands

docker ps isn’t the only command with a default you can set. For example, imagesFormat does the same for docker images:

{
  "psFormat": "table {{.ID}}\t{{.Image}}\t{{.Names}}",
  "imagesFormat": "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
}

The Docker CLI documentation lists all the configuration keys.

docker compose ps takes a --format template too, with its own fields, such as {{.Service}}:

docker compose ps --format "table {{.Name}}\t{{.Service}}\t{{.Status}}"

Alias

With a short default in place, I use a shell alias for the other view I need most, the ports:

alias dps='docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"'

docker inspect Is Different

docker inspect also takes --format, but it uses the full container data from the Docker API, so its field names are different, and you can reach nested fields:

docker inspect --format "{{.Id}} {{.State.Status}}" myapp-db-1

Summary

Use --format with a table template to choose the columns docker ps shows.

Use {{json .}} to find the field names, and remember they are case-sensitive.

Set psFormat in ~/.docker/config.json to make your template the default.

Docker documentation for formatting output:

docs.docker.com/engine/cli/formatting