PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 6, 2022

[FIXED] How to display total number of running containers in docker?

 November 06, 2022     docker     No comments   

Issue

docker ps

Displays all the running containers

I want to display the total number of running containers

The command,

docker ps | wc -l

displays the line count but also counts headers as lines.

How do I exclude headers? Also, is there another way to print the total number of running containers?


Solution

docker info display the number of running containers like next:

Server:
Containers: 116
 Running: 3
 Paused: 0
 Stopped: 113

You could format the output using next to get the running containers:

$ docker info --format '{{json .ContainersRunning}}'
3


Answered By - atline
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing