• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Docker

Listing Docker Containers

July 8, 2024
in Docker, Docker Commands Examples, Docker Commands Tutorial, Docker Tutorial
A A
0
11
SHARES
100
VIEWS
Share on FacebookShare on Twitter

This post will cover topic related to ‘Listing Docker Containers’ with multiple docker command examples and different scenerios. So this will help you to understand the command docker and options available in it. Also this post will explain you how to use docker command.

Docker is a powerful tool for containerization that allows developers to package applications and their dependencies into lightweight containers. The docker ps command is used for listing Docker containers currently running on your system.

Here are several examples of how you can use docker ps to manage and inspect Docker containers:

Example 1: List all running containers.
docker ps
Output: Displays a table with details of all active containers including their IDs, names, status, and ports.

Example 2: List all containers (including stopped ones).
docker ps -a
Output: Shows a list of all containers, both running and stopped, with detailed information.

Example 3: Display only container IDs.
docker ps -q
Output: Prints only the numeric IDs of the active containers, which is useful for scripting or automation tasks.

Example 4: Display the latest created containers.
docker ps -l
Output: Shows information about the last container created, whether it’s running or stopped.

Example 5: List containers by most recent first.
docker ps -n 5
Output: Limits the output to the last 5 containers created, useful for viewing recent activity.

Example 6: Display only container IDs of the last 3 created containers.
docker ps -n 3 -q
Output: Lists only the IDs of the last 3 containers created, suitable for quick identification.

Example 7: Display containers in reverse order.
docker ps -q -s
Output: Shows container IDs in reverse order of their creation time, displaying the sizes as well.

Example 8: Display total file sizes.
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"
Output: Customizes the output format to display specific container details like ID, image, status, and ports in a table format.

Example 9: Display containers by specifying a custom format.
docker ps --format "{{.ID}}: {{.Command}} ({{.Status}})"
Output: Formats the output to show container IDs, commands, and statuses in a user-defined format.

Example 10: Display containers with a specific name pattern.
docker ps --filter "name=mycontainer"
Output: Filters and displays containers whose names match the specified pattern, useful for targeted searches.

To verify whether the docker ps command executed successfully, you can check the terminal output for the list of containers. If the command was executed without errors, it will display a table or list of containers along with their details. This confirms that Docker was able to retrieve and display the container information as requested.

Also check similar articles.

Executing Commands Inside Docker Containers
How to Create and Run Docker Containers from an Image
How to Manage Kubernetes Plugins
How to Manage Kubernetes Networks
How to Manage Kubernetes Image Manifests

Tags: DockerDocker Commands ExamplesDocker Commands TutorialDocker Tutorial
Previous Post

Executing Commands Inside Docker Containers

Next Post

Building Docker Images from a Dockerfile

Related You may like!

howto

Managing Swarm Services

August 21, 2024
howto

Managing Docker Volumes

August 21, 2024

Managing Docker Networks

August 21, 2024

Managing Swarm Secrets

July 8, 2024

Managing Swarm Nodes

July 8, 2024

Managing Swarm Configurations

July 8, 2024
Next Post
howto

Building Docker Images from a Dockerfile

howto

Downloading Docker Images from a Registry

howto

Uploading Docker Images to a Registry

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Using BTRFS Subvolume for User Home Directory in Linux

    22 shares
    Share 9 Tweet 6
  • Downloading Docker Images from a Registry

    13 shares
    Share 5 Tweet 3
  • Configuring SSL Connection Mode in mysqldump

    17 shares
    Share 7 Tweet 4
  • Omit Tablespace Information in mysqldump Output

    13 shares
    Share 5 Tweet 3
  • Setting MySQL Dump Compatibility Mode

    18 shares
    Share 7 Tweet 5
  • Setting Network Buffer Length in mysqldump

    13 shares
    Share 5 Tweet 3
  • Logging out from Docker Registries

    13 shares
    Share 5 Tweet 3
  • Scheduling Nodes in Kubernetes with kubectl uncordon

    12 shares
    Share 5 Tweet 3
  • Managing Default User Creation Settings in Linux

    15 shares
    Share 6 Tweet 4
  • Using Extended INSERT Syntax in mysqldump

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.