In our last article I shared the steps to install docker and configure storage to use a thin pool LVM for our docker. Now let’s talk about how to run different Docker container.

Before I show you some command line examples of managing docker containers, let me give you a brief overview on the important terminologies

  • Docker daemon: The daemon managing your Docker containers and images. We call it shortly Docker.
  • Docker engine: This is the Docker infrastructure and workflow process
  • Docker host or Docker node: This is the machine that is running Docker engine.
  • Docker image: This is the contents or the package that we can run as a container. It provides the base operating system, and the application, and it contains only read only layers, and no read write layers.
  • Container: An instantiated version of an image. It is the instance that we run on top of the image, and that contains all the read only layers, plus the read write layer that is added on top.

Tutorial_ How to manage docker container with examples

NOTE:
So an image is instantiated, and is called a container when it’s running on Docker. Images are just immutable contents, and containers are instantiated, get a mutable layer added on the top, and it can have states like stopped, and start, and running, and so on.

 

Let me show you some examples

 

Check status of docker

Before we start with the configuration it is important to make sure our docker service is running

[[email protected] ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2018-12-20 20:20:49 IST; 16h ago
     Docs: https://docs.docker.com
 Main PID: 1153 (dockerd)
    Tasks: 32
   Memory: 147.3M
   CGroup: /system.slice/docker.service
           ├─1153 /usr/bin/dockerd -H unix://
           ├─1289 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
           └─4299 containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/3cf05b3c26b75eb15f181b9c35d55808e49e1935c4e9d3dedbc71...

Dec 21 12:29:12 node1.example.com dockerd[1153]: time="2018-12-21T12:29:12.179448931+05:30" level=info msg="shim reaped" id=9c79938cb73755e96de571bcd3a513a6262e1005f5e2679...25b48357aa2
Dec 21 12:29:12 node1.example.com dockerd[1153]: time="2018-12-21T12:29:12.189968766+05:30" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/task...TaskDelete"
Dec 21 12:29:22 node1.example.com dockerd[1153]: time="2018-12-21T12:29:22.762710751+05:30" level=info msg="shim containerd-shim started" address="/containerd-shim/moby/e2...se pid=3843
Dec 21 12:29:23 node1.example.com dockerd[1153]: time="2018-12-21T12:29:23.180260570+05:30" level=info msg="shim reaped" id=e28f5a6fd1cbf8c04cefd94fdf8cdf8cdc40dd7723f83e8...4ee43925900
Dec 21 12:29:23 node1.example.com dockerd[1153]: time="2018-12-21T12:29:23.190553007+05:30" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/task...TaskDelete"
Dec 21 12:29:41 node1.example.com dockerd[1153]: time="2018-12-21T12:29:41.052677343+05:30" level=info msg="shim containerd-shim started" address="/containerd-shim/moby/9e...se pid=3957
Dec 21 12:29:41 node1.example.com dockerd[1153]: time="2018-12-21T12:29:41.383996326+05:30" level=info msg="shim reaped" id=9edcb088fe31716fc727b7291e7972f4cb030ff51e29db8...cdaa53bd807
Dec 21 12:29:41 node1.example.com dockerd[1153]: time="2018-12-21T12:29:41.394072301+05:30" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/task...TaskDelete"
Dec 21 12:31:31 node1.example.com dockerd[1153]: time="2018-12-21T12:31:31.571196111+05:30" level=error msg="Error setting up exec command in container 9edcb088fe31716fc72...ot running"
Dec 21 12:33:12 node1.example.com dockerd[1153]: time="2018-12-21T12:33:12.263039550+05:30" level=info msg="shim containerd-shim started" address="/containerd-shim/moby/13...se pid=4299
Hint: Some lines were ellipsized, use -l to show in full.

 

Use normal user to manage docker

Once docker is installed, we will have a group ‘docker‘ available on our system. Any user which is part of docker group will be allowed to execute docker related commands

[[email protected] ~]# grep docker /etc/group
docker:x:980:deepak

So let us add ‘deepak‘ to docker group

[[email protected] ~]# usermod -aG docker deepak

Next switch user to ‘deepak

[[email protected] ~]# su - deepak
Last login: Wed Dec 19 15:41:51 IST 2018 from 10.0.2.2 on pts/1

 

Get information on available docker containers

Docker info is providing information about the current docker environment that we are running. So we have no containers and images that are stored on this machine, we can see the storage driver that we have just configured, and all the different storage capacities, like data space that is used, and we can find more information about the entire docker environment. The docker info command is a useful command to verify what exactly it is that docker currently is doing

[[email protected] ~]$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.09.0
Storage Driver: devicemapper
 Pool Name: vg_docker-thinpool
 Pool Blocksize: 524.3kB
 Base Device Size: 10.74GB
 Backing Filesystem: xfs
 Udev Sync Supported: true
 Data Space Used: 20.45MB
 Data Space Total: 8.154GB
 Data Space Available: 8.133GB
 Metadata Space Used: 8.434MB
 Metadata Space Total: 83.89MB
 Metadata Space Available: 75.45MB
 Thin Pool Minimum Free Space: 815.3MB
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.149-RHEL7 (2018-07-20)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-957.1.3.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.701GiB
Name: node1.example.com
ID: 2JHJ:HICZ:HHVG:NUOA:FCAK:EFJI:RDAF:LFPH:XZUA:WFER:DI7I:LOEI
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

 

Docker Hello World

Now let’s start with the first command, which is docker run hello-world. Docker Hub provides a docker image with the name hello world that allows you to run hello world.

Since the docker image is not available on our system, it is pulling (downloading) the image from it’s repo which will take some time.

[[email protected] ~]$ docker run hello-world
Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

You can see the summary of what this image has done displayed here on my screen.

  • So Docker client contacted the Docker daemon,
  • Docker daemon pulled hello world from Docker Hub,
  • and Docker daemon created a new container from that image, which runs the executable that produces the output that we are currently reading.

 

So basically, it downloaded an image, it started container, it ran the commands, and then it exited.

 

To get an overview of currently running Docker containers, use ‘docker ps

[[email protected] ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

and if you want to get an overview of all Docker containers that have been running, but who are exited, use ‘docker ps -a

[[email protected] ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ea540759dd3c        hello-world         "/hello"            31 seconds ago      Exited (0) 29 seconds ago               eloquent_chandrasekhar

Now this is useful information as well, because we can see the hello world images we used to run the command hello.
It was created 31 seconds ago, and it exited 29 seconds ago, and it has a logical name, eloquent_chandrasekhar.
These logical names are generated automatically, and you can use them to manage containers in an easier way. I mean, dazzling gates is a little bit easier to type than this container id.

 

Download ubuntu container image

To try something more ambitious, you can run an Ubuntu container with ‘bash‘. This command will download the Ubuntu image, in case it’s not yet present on this local machine, and it will start an interactive terminal mode, in which the command bash is executed, and the result is that we suddenly are in bash shell.

[[email protected] ~]$ docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
32802c0cfa4d: Pull complete
da1315cffa03: Pull complete
fa83472a3562: Pull complete
f85999a86bef: Pull complete
Digest: sha256:6d0e0c26489e33f5a6f0020edface2727db9489744ecc9b4f50c7fa671f23c49
Status: Downloaded newer image for ubuntu:latest
[email protected]:/# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.3  0.0  18496  2004 pts/0    Ss   05:53   0:00 bash
root        10  0.0  0.0  34388  1464 pts/0    R+   05:53   0:00 ps aux

Also, other commands do relate to what we have in this container. You can see the thin provision volume that this container is using, with the size of 10 GB, and a used size of 107 MB. It’s thin provisioned, so this is not really using any storage on your computer.

[email protected]:/# df -h
Filesystem                                                                                        Size  Used Avail Use% Mounted on
/dev/mapper/docker-253:0-529717-a4cf6f4fbccc8c390d4558e357ecb99574fc8bcebaf6b0df498a6a1811ada898   10G  107M  9.9G   2% /
tmpfs                                                                                              64M     0   64M   0% /dev
tmpfs                                                                                             1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root                                                                            16G  8.2G  6.5G  56% /etc/hosts
shm                                                                                                64M     0   64M   0% /dev/shm
tmpfs                                                                                             1.9G     0  1.9G   0% /proc/acpi
tmpfs                                                                                             1.9G     0  1.9G   0% /proc/scsi
tmpfs                                                                                             1.9G     0  1.9G   0% /sys/firmware

 

How to exit from container?

To exit from a container, use control+p followed by control+q, and that will bring you back to a normal shell environment.

[email protected]:/# [[email protected] ~]$

Now if we check for any running containers using ps, we will see ‘ubuntu

[[email protected] ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
3cf05b3c26b7        ubuntu              "bash"              2 minutes ago       Up 2 minutes                            suspicious_lamport

 

How to stop a container?

Now to stop a container you can simply run docker stop followed by the name of the container which for us is suspicious_lamport

[[email protected] ~]$ docker stop suspicious_lamport
suspicious_lamport

Next check the status again, which shows nothing. So there are no running containers at the moment

[[email protected] ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Now let us get an history of containers which were running on our system. It shows that ubuntu was created 4 minutes ago but exited 33 seconds ago

[[email protected] ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
3cf05b3c26b7        ubuntu              "bash"              4 minutes ago       Exited (0) 33 seconds ago                       suspicious_lamport
ea540759dd3c        hello-world         "/hello"            7 minutes ago       Exited (0) 7 minutes ago                        eloquent_chandrasekhar

[[email protected] ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
3cf05b3c26b7        ubuntu              "bash"              9 seconds ago       Up 9 seconds                            suspicious_lamport

 

How to connect to a docker container?

Once you have started a docker container that is not in interactive mode, if you want to run something within it, you can use docker exec

[[email protected] ~]$ docker exec -it suspicious_lamport bash
[email protected]:/# read escape sequence

So docker exec is a useful command that allows you to get into a container, and to perform specific tasks within the container.
Now to exit from a container, use control+p followed by control+q, and that will bring you back to a normal shell environment.

 

How to remove docker container?

If you want to remove the docker container from your system to save some disk space, that is possible as well. You should use docker rm, followed by the name of the container, which is suspicious_lamport for our case.

[[email protected] ~]$ docker rm suspicious_lamport
suspicious_lamport

This has removed the container.

[[email protected] ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
ea540759dd3c        hello-world         "/hello"            7 minutes ago       Exited (0) 7 minutes ago                       eloquent_chandrasekhar

If you also want to remove the image, that is also possible, and you will use docker rmi to do so. So docker rmi ubuntu will delete all of the different layers that are available in the Ubuntu image

[[email protected] ~]$ docker rmi ubuntu
Untagged: ubuntu:latest
Untagged: [email protected]:6d0e0c26489e33f5a6f0020edface2727db9489744ecc9b4f50c7fa671f23c49
Deleted: sha256:93fd78260bd1495afb484371928661f63e64be306b7ac48e2d13ce9422dfee26
Deleted: sha256:1c8cd755b52d6656df927bc8716ee0905853fada7ca200e4e6954bd010e792bb
Deleted: sha256:9203aabb0b583c3cf927d2caf6ba5b11124b0a23f8d19afadb7b071049c3cf26
Deleted: sha256:32f84095aed5a2e947b12a3813f019fc69f159cb5c7eae5dad69b2d98ffbeca4
Deleted: sha256:bc7f4b25d0ae3524466891c41cefc7c6833c533e00ba80f8063c68da9a8b65fe

 

How to query Docker Hub?

Now let’s query the Docker Hub some more. This allows us to look for different CentOS images that are available.

[[email protected] ~]$ docker search CentOS
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   5062                [OK]
ansible/centos7-ansible            Ansible on Centos7                              119                                     [OK]
jdeathe/centos-ssh                 CentOS-6 6.10 x86_64 / CentOS-7 7.5.1804 x86…   102                                     [OK]
consol/centos-xfce-vnc             Centos container with "headless" VNC session…   73                                      [OK]
imagine10255/centos6-lnmp-php56    centos6-lnmp-php56                              48                                      [OK]
centos/mysql-57-centos7            MySQL 5.7 SQL database server                   44
tutum/centos                       Simple CentOS docker image with SSH access      43
gluster/gluster-centos             Official GlusterFS Image [ CentOS-7 +  Glust…   38                                      [OK]
openshift/base-centos7             A Centos7 derived base image for Source-To-I…   37
centos/postgresql-96-centos7       PostgreSQL is an advanced Object-Relational …   35
centos/python-35-centos7           Platform for building and running Python 3.5…   32
kinogmt/centos-ssh                 CentOS with SSH                                 25                                      [OK]
openshift/jenkins-2-centos7        A Centos7 based Jenkins v2.x image for use w…   19
centos/php-56-centos7              Platform for building and running PHP 5.6 ap…   17
pivotaldata/centos-gpdb-dev        CentOS image for GPDB development. Tag names…   9
openshift/wildfly-101-centos7      A Centos7 based WildFly v10.1 image for use …   6
openshift/jenkins-1-centos7        DEPRECATED: A Centos7 based Jenkins v1.x ima…   4
darksheer/centos                   Base Centos Image -- Updated hourly             3                                       [OK]
pivotaldata/centos                 Base centos, freshened up a little with a Do…   2
pivotaldata/centos-mingw           Using the mingw toolchain to cross-compile t…   2
pivotaldata/centos-gcc-toolchain   CentOS with a toolchain, but unaffiliated wi…   1
blacklabelops/centos               CentOS Base Image! Built and Updates Daily!     1                                       [OK]
smartentry/centos                  centos with smartentry                          0                                       [OK]
pivotaldata/centos7-build          CentosOS 7 image for GPDB compilation           0
pivotaldata/centos7-test           CentosOS 7 image for GPDB testing               0

Here we can see that the name is CentOS, the description is the official build of CentOS.

 

If it says it’s the official build of CentOS, and normally this is created by the provider of the software. The start indicates the appreciation level, it has 5,062 starts, which means that this is a pretty reliable image. You can see other images as well, such as this one, which have not been appreciated with any start, which means that nobody has approved of it so far. That doesn’t mean anything, it just means that this is not a commonly used container image. So if you are using for something reliable, then this is probably the thing that you wanna use. Officially it’s indicating that it’s the official release.

 

Similarly if you want to find a specific operating system, or search for a solution, like docker search mariadb, and then you can see a lot of mariadb results are being displayed. Now let us download the different image layers of mariadb, and run the Docker container on this system.

[[email protected] ~]# docker run mariadb
Unable to find image 'mariadb:latest' locally
latest: Pulling from library/mariadb
32802c0cfa4d: Already exists
da1315cffa03: Already exists
fa83472a3562: Already exists
f85999a86bef: Already exists
a2434d5c8419: Already exists
181debc3d23d: Already exists
7b5b2b6de4ee: Already exists
6f830a8cb936: Already exists
c6becfb25371: Already exists
a57998e3e98d: Already exists
26444682043c: Already exists
9bbb07a72de5: Pull complete
84b75eddf6b1: Pull complete
9f45ae7e5c8d: Pull complete
Digest: sha256:12e32f8d1e8958cd076660bc22d19aa74f2da63f286e100fb58d41b740c57006
Status: Downloaded newer image for mariadb:latest
error: database is uninitialized and password option is not specified
  You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

Now you can see that the container is complaining about the database, this uninitialized impassive option is not specified, so this container apparently need some more information in order to do its work.

 

Here as you see our mariadb container exited 17 minutes ago.

[[email protected] ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS               NAMES
4e67a25166ff        mariadb             "docker-entrypoint.s…"   17 minutes ago      Exited (1) 17 minutes ago                          angry_poitras
ea540759dd3c        hello-world         "/hello"                 About an hour ago   Exited (0) About an hour ago                       eloquent_chandrasekhar

 

How to check Docker logs?

There’s one more thing that I would like to discuss about managing containers, and that is debugging, finding out what is happening within a container. Docker logs may be useful. You can use these commands on a container to get information from the standard out and the standard error on the container’s console, provided that any such thing has been generated

[[email protected] ~]$ docker logs suspicious_lamport

Here suspicious_lamport was our ubuntu container. Now since there are no errors the output is blank.

Let us check the logs of mariadb container

[[email protected] ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS               NAMES
3cf05b3c26b7        ubuntu              "bash"                   2 minutes ago       Up 2 minutes                                       suspicious_lamport
4e67a25166ff        mariadb             "docker-entrypoint.s…"   37 minutes ago      Exited (1) 37 minutes ago                          angry_poitras
ea540759dd3c        hello-world         "/hello"                 About an hour ago   Exited (0) About an hour ago                       eloquent_chandrasekhar

Now as you see the error message which we observed while running the mariadb container

[[email protected] ~]$ docker logs angry_poitras
error: database is uninitialized and password option is not specified
  You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

To get more information on the container. This is all the information that has been used while creating the container.

[[email protected] ~]$ docker inspect suspicious_lamport
[
    {
        "Id": "3cf05b3c26b75eb15f181b9c35d55808e49e1935c4e9d3dedbc7180261c41fe2",
        "Created": "2018-12-21T07:03:12.007684767Z",
        "Path": "bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 4318,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2018-12-21T07:03:12.548723701Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:93fd78260bd1495afb484371928661f63e64be306b7ac48e2d13ce9422dfee26",
        "ResolvConfPath": "/var/lib/docker/containers/3cf05b3c26b75eb15f181b9c35d55808e49e1935c4e9d3dedbc7180261c41fe2/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/3cf05b3c26b75eb15f181b9c35d55808e49e1935c4e9d3dedbc7180261c41fe2/hostname",
        "HostsPath": "/var/lib/docker/containers/3cf05b3c26b75eb15f181b9c35d55808e49e1935c4e9d3dedbc7180261c41fe2/hosts",
        "LogPath": "/var/lib/docker/containers/3cf05b3c26b75eb15f181b9c35d55808e49e1935c4e9d3dedbc7180261c41fe2/3cf05b3c26b75eb15f181b9c35d55808e49e1935c4e9d3dedbc7180261c41fe2-json.log",
        "Name": "/suspicious_lamport",
        "RestartCount": 0,
        "Driver": "devicemapper",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": [
            "cb6e6974f1513f7ea509a1f657838741b129a167771779c078119dbbc79a6129"
        ],
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/asound",
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "DeviceId": "36",
                "DeviceName": "docker-253:0-529717-1443554881a9ad438000d94d8b883ca60ed5a75ebcdd9e9a1f8ed40b2840b03b",
                "DeviceSize": "10737418240"
            },
            "Name": "devicemapper"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "3cf05b3c26b7",
            "Domainname": "",
            "User": "",
            "AttachStdin": true,
            "AttachStdout": true,
            "AttachStderr": true,
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": true,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "bash"
            ],
            "Image": "ubuntu",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "e30994015e7aca47e373bc0a45daed8b46b7b62ee5c78a6842ed35d17513619f",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/e30994015e7a",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "d51c7efd781bbec0524030c731d5bcefe1677a5ddc5a31fde1f51effb23d0ab5",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "5a92284fb69d2fff9dd226e8dd962e199b8e6f76b92737e9cf867f21bbbb84ac",
                    "EndpointID": "d51c7efd781bbec0524030c731d5bcefe1677a5ddc5a31fde1f51effb23d0ab5",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

]

So we can see some current state information. We can see the image that is currently used. We can also see the storage it is using in a var lib container, followed by the container ID. We can see information about the configuration of the container, and if you scroll down, we can also see information about networking, for instance. So here we can see the network settings, including the IP address that is being used by this container, which is 172.17.0.2.

 

Leave a Reply

Your email address will not be published. Required fields are marked *