Answers: <pre><code>docker ps -a |  grep -v Exited | cut -c1-$COLUMNS
  </code></pre>
  <p>Depending on desired columns this is a good starting point to obtain a nice display of all running containers for human consumption ... it auto handles when you resize terminal window using env var COLUMNS</p>
  <pre><code>CONTAINER ID   IMAGE                                               COMMAND                  CREATED             STATUS           
  0677a58056f3   loud_clamav/av                                      &quot;/bootstrap.sh&quot;          24 minutes ago      Up 24 minutes (he
  ee374532c1bb   localhost:5000/hygge/loudweb-enduser                &quot;/usr/bin/supervisor…&quot;   24 minutes ago      Up 24 minutes  
  5546cd73ebcc   localhost:5000/hygge/loudweb-admin                  &quot;/usr/bin/supervisor…&quot;   24 minutes ago      Up 24 minutes  
  5e7c55a950b1   mongo                                               &quot;docker-entrypoint.s…&quot;   24 minutes ago      Up 24 minutes  
  505909fa4490   mcr.microsoft.com/mssql/server:2017-latest-ubuntu   &quot;/opt/mssql/bin/nonr…&quot;   30 minutes ago      Up 30 minutes  
  a1ea1d2882f5   localhost:5000/hygge/loudweb-dind/2204280434        &quot;/usr/bin/supervisor…&quot;   About an hour ago   Up 24 minutes  
  4713b632a08f   tvial/docker-mailserver:latest                      &quot;supervisord -c /etc…&quot;   43 hours ago        Up 24 minutes  
  010da9fc7fd5   registry:2.7.0                                      &quot;/entrypoint.sh /etc…&quot;   43 hours ago        Up About an hou
  o
  </code></pre>
  <p>the big benefit of above command is dynamically handles current size of your terminal where you executed the command ( notice the use of COLUMNS env var)</p>
  <p>naturally you can create an alias as a shortcut to run this command just save below in your file <code>~/.bashrc</code>  which allows you to just type in  <code>dpss</code></p>
  <pre><code>alias dpss='docker ps -a |  grep -v Exited | cut -c1-$COLUMNS ' #  truncate width shows driven by current terminal size ... to avoid line wrapping
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-01-16T04:49:37.247Z
Answers: Just to be certain, do the grep before the cut.
Answers: Thorbjørn Ravn Andersen
Answers: CC BY-SA 4.0
Answers: 2023-01-13T13:52:33.447Z
Answers: 2023-01-16T11:41:51.573Z
Answers: 2023-01-16T11:41:51.573Z
Answers: Scott Stensland
Answers: <p>As a possible alternative to using shell pipes, check out the <a href="https://docs.docker.com/engine/reference/commandline/ps/#filter" rel="nofollow noreferrer"><code>--filter</code></a> and <a href="https://docs.docker.com/engine/reference/commandline/ps/#format" rel="nofollow noreferrer"><code>--format</code></a> options of <code>docker ps</code>. (<a href="https://docs.docker.com/engine/reference/commandline/ps/#no-trunc" rel="nofollow noreferrer"><code>--no-trunc</code></a> is also handy sometimes.)</p>
  <p>For example, the output of <code>docker ps -a |  grep -v Exited | cut -c1-$COLUMNS</code> can be approximated by the following command:</p>
  <p><code>docker ps -a --filter 'status=running' --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.RunningFor}}\t{{.Status}}'</code></p>
  <p>('approximated' because filter expressions annoyingly don't support NOT-operations and <code>status=running</code> is not exactly the same as <code>NOT exited</code>. Plus you don't get the neat auto-truncation of columns.)</p>
  <p>Downside is that you have to grapple with a new DSL (Go templates) that might not be as familiar as shell pipelines. On the plus side, <code>--format</code> allows you to shape the output in any way that you see fit, e.g.</p>
  <pre><code>$ docker ps --format '{{.Image}}: {{.Command}}'
  netdata/netdata: &quot;/usr/sbin/run.sh&quot;
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-06-16T15:56:52.443Z
Answers: 2023-06-16T16:04:48.850Z
Answers: 2023-06-16T16:04:48.850Z
Answers: afrischke
Body: <p>Default layout of output from  <code>docker ps</code> is somewhat unwieldy ... how to get a better presentation of all locally running docker containers from terminal on linux ?</p>
  <p>For context below is output from <code>docker ps</code> as viewed from terminal for human consumption</p>
  <p><a href="https://i.sstatic.net/B4V0k.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/B4V0k.png" alt="enter image description here" /></a></p>
  
Comments: CC BY-SA 4.0
Comments: 2023-01-16T04:48:41.123Z
Comments: pipe to `less -S`
Comments: Thorbjørn Ravn Andersen
Tags: <docker><linux>
Title: show running docker containers nicely formatted
UserDisplayName: Scott Stensland
ThreadText: # show running docker containers nicely formatted
  
  (Asked by: username_0 on 2023-01-13)
  
  Default layout of output from `docker ps` is somewhat unwieldy ... how to get a better presentation of all locally running docker containers from terminal on linux ?
  
  For context below is output from `docker ps` as viewed from terminal for human consumption
  
  [![enter image description here](https://i.sstatic.net/B4V0k.png)](https://i.sstatic.net/B4V0k.png)
  
  **Tags:** docker, linux
  
  > **Comments:**
  > **username_1**: pipe to `less -S`  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2023-01-13. Score: 0 | Accepted answer
  
  ```
  docker ps -a |  grep -v Exited | cut -c1-$COLUMNS
  
  ```
  
  Depending on desired columns this is a good starting point to obtain a nice display of all running containers for human consumption ... it auto handles when you resize terminal window using env var COLUMNS
  
  ```
  CONTAINER ID   IMAGE                                               COMMAND                  CREATED             STATUS           
  0677a58056f3   loud_clamav/av                                      "/bootstrap.sh"          24 minutes ago      Up 24 minutes (he
  ee374532c1bb   localhost:5000/hygge/loudweb-enduser                "/usr/bin/supervisor…"   24 minutes ago      Up 24 minutes  
  5546cd73ebcc   localhost:5000/hygge/loudweb-admin                  "/usr/bin/supervisor…"   24 minutes ago      Up 24 minutes  
  5e7c55a950b1   mongo                                               "docker-entrypoint.s…"   24 minutes ago      Up 24 minutes  
  505909fa4490   mcr.microsoft.com/mssql/server:2017-latest-ubuntu   "/opt/mssql/bin/nonr…"   30 minutes ago      Up 30 minutes  
  a1ea1d2882f5   localhost:5000/hygge/loudweb-dind/2204280434        "/usr/bin/supervisor…"   About an hour ago   Up 24 minutes  
  4713b632a08f   tvial/docker-mailserver:latest                      "supervisord -c /etc…"   43 hours ago        Up 24 minutes  
  010da9fc7fd5   registry:2.7.0                                      "/entrypoint.sh /etc…"   43 hours ago        Up About an hou
  o
  
  ```
  
  the big benefit of above command is dynamically handles current size of your terminal where you executed the command ( notice the use of COLUMNS env var)
  
  naturally you can create an alias as a shortcut to run this command just save below in your file `~/.bashrc` which allows you to just type in `dpss`
  
  ```
  alias dpss='docker ps -a |  grep -v Exited | cut -c1-$COLUMNS ' #  truncate width shows driven by current terminal size ... to avoid line wrapping
  
  ```
  
  > **Comments:**
  > **username_1**: Just to be certain, do the grep before the cut.  
  
  ---
  
  ### Answer by username_2 on 2023-06-16. Score: 0
  
  As a possible alternative to using shell pipes, check out the [`--filter`](https://docs.docker.com/engine/reference/commandline/ps/#filter) and [`--format`](https://docs.docker.com/engine/reference/commandline/ps/#format) options of `docker ps`. ([`--no-trunc`](https://docs.docker.com/engine/reference/commandline/ps/#no-trunc) is also handy sometimes.)
  
  For example, the output of `docker ps -a | grep -v Exited | cut -c1-$COLUMNS` can be approximated by the following command:
  
  `docker ps -a --filter 'status=running' --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.RunningFor}}\t{{.Status}}'`
  
  ('approximated' because filter expressions annoyingly don't support NOT-operations and `status=running` is not exactly the same as `NOT exited`. Plus you don't get the neat auto-truncation of columns.)
  
  Downside is that you have to grapple with a new DSL (Go templates) that might not be as familiar as shell pipelines. On the plus side, `--format` allows you to shape the output in any way that you see fit, e.g.
  
  ```
  $ docker ps --format '{{.Image}}: {{.Command}}'
  netdata/netdata: "/usr/sbin/run.sh"
  
  ```
  
  
  ---
  
  