E-mail : support@tech2now.in

Docker Installation Status and Useful Commands

Docker Containers
Open a terminal window and run the following command to check the installed Docker version
[root@localhost ~]# docker --version
Docker version 1.13.1, build 7d71120/1.13.1
List Running Containers
To see if any containers are currently running, use the following command
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                         PORTS               NAMES
c59aa50b95dc        hello-world         "/hello"            About an hour ago   Exited (0) About an hour ago                       tender_wozniak
Docker imagesList all the available Docker images stored locally
[root@localhost ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              9c7a54a9a43c        4 months ago        13.3 kB
To search for a Docker image, centos.
[root@localhost ~]# docker search centos
INDEX       NAME                                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/centos                                       DEPRECATED; The official build of CentOS.       7643      [OK]
docker.io   docker.io/kasmweb/centos-7-desktop                     CentOS 7 desktop for Kasm Workspaces            39
docker.io   docker.io/couchbase/centos7-systemd                    centos7-systemd images with additional deb...   8                    [OK]
docker.io   docker.io/dokken/centos-stream-9                                                                       6
docker.io   docker.io/dokken/centos-7                              CentOS 7 image for kitchen-dokken               5
docker.io   docker.io/eclipse/centos_jdk8                          CentOS, JDK8, Maven 3, git, curl, nmap, mc...   5                    [OK]
docker.io   docker.io/dokken/centos-stream-8                                                                       4

To Download it locally by running the below command

[root@localhost ~]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for docker.io/centos:latest

Check Docker image on the host

[root@localhost ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              9c7a54a9a43c        4 months ago        13.3 kB
docker.io/centos        latest              5d0da3dc9764        24 months ago       231 MB

Run an interactive session into a container

[root@localhost ~]# docker run -dit centos
ab7f19d58684b45d991d38ca71c4ed57ef87d22aea3cff1d57e90af16d54d117

Check all the running containers

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                         PORTS               NAMES
ab7f19d58684        centos              "/bin/bash"         About a minute ago   Up About a minute                                  fervent_elion
c59aa50b95dc        hello-world         "/hello"            About an hour ago    Exited (0) About an hour ago                       tender_wozniak

To remove all the containers run the below commands

[root@localhost ~]# docker rm `docker ps -a -q` -f
ab7f19d58684
c59aa50b95dc

To remove all the images run the below commands

[root@localhost ~]# docker rmi docker images -q -f
Untagged: docker.io/hello-world:latest
Untagged: docker.io/hello-world@sha256:dcba6daec718f547568c562956fa47e1b03673dd010fe6ee58ca806767031d1c
Deleted: sha256:9c7a54a9a43cca047013b82af109fe963fde787f63f9e016fdc3384500c2823d
Deleted: sha256:01bb4fce3eb1b56b05adf99504dafd31907a5aadac736e36b27595c8b92f07f1
Untagged: docker.io/centos:latest
Untagged: docker.io/centos@sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Deleted: sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6
Deleted: sha256:74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE