Languages
[Edit]
EN

Docker - list only container ids

4 points
Created by:
JustMike
3590

In this short article we would like to show how to list ids of run containers in Docker.

Quick solution (run following command):

docker ps -q

Output:

d76423e8e259
f44b6ffcee6a
25605bf8dc3f
c14692b929b2
8867d0ac1ed1
252ab6485893

Alternative solution

The approach presented in the section cuts first field that is Container ID and removes column heading.

Command example:

docker ps | cut -f 1 -d " " | tail -n +2

Output:

d76423e8e259
f44b6ffcee6a
25605bf8dc3f
c14692b929b2
8867d0ac1ed1
252ab6485893
Hey 👋
Would you like to know what we do?
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.