0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

How to show specific column with docker ps command

Last updated at Posted at 2024-05-16

How to show specific column with docker ps command

Refs

Prerequisite

  • jq command

First Example

# docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}"
CONTAINER ID   NAMES              STATUS
6649ac512517   jupyter-notebook   Up 15 hours (healthy)
adc3f126a364   cadvisor           Up 3 weeks (healthy)
45c106f51a6e   mailserver         Up 3 weeks (healthy)
f34501c9a42e   docker_exporter    Up 32 hours

What column name is available?

  • Get available column names with json key name!
# docker container ls --format='{{json .}}' | jq -rcs '.[0] | keys[]'
Command
CreatedAt
ID
Image
Labels
LocalVolumes
Mounts
Names
Networks
Ports
RunningFor
Size
State
Status

Second Examples

# docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Size}}"
CONTAINER ID   NAMES              STATUS                  SIZE
6649ac512517   jupyter-notebook   Up 15 hours (healthy)   3.27MB (virtual 4.41GB)
adc3f126a364   cadvisor           Up 3 weeks (healthy)    0B (virtual 80.8MB)
45c106f51a6e   mailserver         Up 3 weeks (healthy)    764kB (virtual 629MB)
f34501c9a42e   docker_exporter    Up 32 hours             0B (virtual 57.2MB)
# docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Image}}\t{{.Size}}"
CONTAINER ID   NAMES              STATUS                  IMAGE
6649ac512517   jupyter-notebook   Up 15 hours (healthy)   jupyter_20240419/scipy-notebook:2023-08-19
adc3f126a364   cadvisor           Up 3 weeks (healthy)    gcr.io/cadvisor/cadvisor:v0.49.1
45c106f51a6e   mailserver         Up 3 weeks (healthy)    ghcr.io/docker-mailserver/docker-mailserver:latest
f34501c9a42e   docker_exporter    Up 32 hours             prometheusnet/docker_exporter
# docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"
# docker ps --no-trunc --format "table {{.Names}}\t{{.Mounts}}"
NAMES              MOUNTS
pihole             /root/docker-compose/etc-dnsmasq.d,/root/docker-compose/etc-pihole
postgres_na24.2    /docker-postgres/na24.2/data
postgres_na23.4    /docker-postgres/na23.4/data
postgres_oo24.1    /docker-postgres/oo24.1/data
jupyter-notebook
jira2              jiraVolume
cadvisor           /var/lib/docker,/var/run,/dev/disk,/,/sys
mailserver         /etc/localtime,/docker-data/dms/config,/docker-data/dms/mail-logs,/docker-data/dms/mail-data,/docker-data/dms/mail-state
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?