skip to Main Content

I want to get status of docker containers with only names and status. I tried below but showing only status

sudo docker ps --format '{{.Names}}' --format '{{.Status}}'

Up 10 days (healthy)

With docker command could we get only container name and status

I want output similar like below,

container-Name | status
memcached      | Up 10 days (healthy)

2

Answers


  1. you can have it by running this:

    docker ps --format "table {{.ID}} | {{.Status}}"
    

    This is the documentation on how to format docker ps

    Login or Signup to reply.
  2. enter image description here
    You can use like this

    docker ps --format "{{.ID}}     {{.Status}}"
    
    
                    OR
    docker ps --format "{{.ID}}||{{.Status}}"
    

    enter image description here
    Thanks @Root
    Reference:
    https://docs.docker.com/engine/reference/commandline/ps/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search