Saturday, 8 November 2025

Docker - Some useful docker command

1. To get help

[root@devopsvm01 ~]# docker <command> --help

[root@devopsvm01 ~]# docker run --help


1. To check docker version

[root@devopsvm01 ~]# docker version

Client: Docker Engine - Community

 Version:           28.5.2

 API version:       1.51

 Go version:        go1.25.3

 Git commit:        ecc6942

 Built:             Wed Nov  5 14:45:59 2025

 OS/Arch:           linux/amd64

 Context:           default

Server: Docker Engine - Community

 Engine:

  Version:          28.5.2

  API version:      1.51 (minimum version 1.24)

  Go version:       go1.25.3

  Git commit:       89c5e8f

  Built:            Wed Nov  5 14:42:52 2025

  OS/Arch:          linux/amd64

  Experimental:     false

 containerd:

  Version:          v1.7.29

  GitCommit:        442cb34bda9a6a0fed82a2ca7cade05c5c749582

 runc:

  Version:          1.3.3

  GitCommit:        v1.3.3-0-gd842d771

 docker-init:

  Version:          0.19.0

  GitCommit:        de40ad0

[root@devopsvm01 ~]#


1. To lists all Docker images stored on your local machine.

[root@devopsvm01 ~]# docker images

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE

hello-world   latest    1b44b5a3e06a   2 months ago   10.1kB

[root@devopsvm01 ~]#


2. To lists all running containers 

[root@devopsvm01 ~]# docker ps

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

[root@devopsvm01 ~]#


3. To lists All containers (running + stopped + exited)

[root@devopsvm01 ~]# docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED          STATUS                      PORTS     NAMES
7666d9a0a66a   hello-world   "/hello"   21 minutes ago   Exited (0) 21 minutes ago             naughty_jepsen
[root@devopsvm01 ~]#


4. How to check docker status 

[root@devopsvm01 ~]# sudo systemctl status docker | head -10
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled)
     Active: active (running) since Mon 2025-11-03 03:06:53 IST; 24min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 106275 (dockerd)
      Tasks: 9
     Memory: 33.3M
        CPU: 506ms
[root@devopsvm01 ~]#

5. How to stop docker

[root@devopsvm01 ~]# sudo systemctl stop docker
Warning: Stopping docker.service, but it can still be activated by:
  docker.socket
[root@devopsvm01 ~]# 

The warning you received, Warning: Stopping docker.service, but it can still be activated by: docker.socket, means that while you successfully stopped the Docker Engine's main daemon process, the system is still configured to automatically restart it if a connection attempt is made to the Docker socket.


[root@devopsvm01 ~]# sudo systemctl status docker | head -7
○ docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled)
     Active: inactive (dead) since Mon 2025-11-03 03:33:48 IST; 1min 24s ago
   Duration: 26min 55.282s
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 106275 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
[root@devopsvm01 ~]#


6. How to start docker.

[root@devopsvm01 ~]# sudo systemctl start docker

[root@devopsvm01 ~]#


7. How to run a conainer

[root@devopsvm01 ~]# docker run <image-name>


8. How to login to remote private repository/hub

[root@devopsvm01 ~]# docker login myregistry.example.com

docker login is needed to perform action like docker pull/psuh

You don’t need to log in to access public repositories.

Anyone can pull images (no login required)





No comments:

Post a Comment

Building a Safer PostgreSQL CI/CD Pipeline with GitHub Actions: Dev → PR Review → Test Promotion

In my previous post, we explored a simple push-to-main deployment strategy . While functional, that model is not considered an industry best...