Reading Time: 16 minutes

What is Docker?

31920.docker

Docker is a containerization software that is used for automating the deployment and management of applications within an isolated environment. This software allows us to "pack" and ship an application, along with all of its needed files, libraries, and dependencies, into a "docker container". That container can then be easily ported to any Linux system that contain cgroups support within the kernel, and provides a container management environment. Docker is one of several containerization implementations (not to be confused with virtualization) based on this cgroups mechanisms built into the Linux kernel.

What are CGroups?

CGroups (or control groups) and namespaces are special mechanisms in the Linux kernel that allows us to isolate and virtualize global system resources of multiple processes. When running an application within this isolated environment, the system must ensure that the application has enough resources. Because of this, it must be aware of, track, manage, audit and restrict the allocation of resources so that the applications do not over consume extra assets, which could disrupt the rest of the system. To solve this problem, cgroups and namespaces was introduced into the Linux kernel.  

Why was Docker Created?

The interesting point of note is that container implementations such as Ubuntu's LXC containerization existed since 2014. So, why was Docker was created? Docker was developed with the thought in mind that we should be able to transfer a container between any type of server without worrying about the configurations or settings. It is important to note that we can run the Docker image on any computer, and it should work equally well without any unnecessary configuration setting changes. These simplified docker images will work with any container as it is platform independent.

What Problems Does Docker Solve?

Because docker allows us to package a complete application, it can be used within multiple system environments types including private clouds, server clusters, or private parent servers. Docker eradicates the problem of missing code, binaries, or incomplete application dependency libraries. It also does away with having to configure applications specifically to a specific OS environment, and removes problems with OS updates affecting the application. Lastly, there are more than 10,000 ready to use docker packaged images that can be pulled in and used without having to create and configure new applications on a system.

What Is a Container?

A container is a type of isolated environment with an application that is runs directly on an OS and not on a virtual machine, within a single environment that shares access to its own resources, inaccessible to other containers. This approach saves processor time and RAM compared to a virtual machine. Linux originally had chroot and various sandboxes.

what is a container
https://www.docker.com/resources/what-container

The virtualized container itself is made from a specially prepared image, but in Docker, the process is much more convenient. A docker image consists of several components, which can be further broken down into other images. The benefits of containerization and options save disk space, network bandwidth, and also reduces the assembly time of the container from the image. Of course, there are also some disadvantages involved. Since the applications are launched from the OS kernel, so we cannot select a different OS from there. The upside is, Docker will run on any OS.

Objectives of Using Docker

In the beginning, the goal of a containerized system like this was primarily for isolation. Solomon Hykes, the creator of Docker, came up with a slightly different approach. He imagined using containers that could deploy an application, with all the assets and attributes included within the container to prevent cluttering up the OS with additional programs. If a container had issues, we could simply deploy a new version of the container. He created this convenient and straightforward process, standardized it, and called it Docker!

We can send an archive of a container to multiple systems and everything will work the same as the original program. We can publicly share an image to a common Docker Hub repository where others can download the image. We can also upload our images there. If it is important to keep the image private, then we can simply create our docker hub on a local network.

Installation

Update Server

First, lets update our server packages.

root@host:~# apt-get -y update && apt-get -y upgrade
Hit:1 http://by.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://by.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://by.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88,7 kB]
Fetched 88,7 kB in 1s (85,8 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root@host:~#

Install Docker

Next, we can install Docker

root@host:~# apt install docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following
packages will be installed:
bridge-utils cgroupfs-mount containerd git git-man liberror-perl pigz runc
ubuntu-fan
Suggested packages:
aufs-tools btrfs-progs debootstrap docker-doc rinse zfs-fuse | zfsutils
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
bridge-utils cgroupfs-mount containerd docker.io git git-man liberror-perl
pigz runc ubuntu-fan
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 68,5 MB of archives.
After this operation, 353 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Get:1 http://by.archive.ubuntu.com/ubuntu bionic/universe amd64 pigz amd64 2.4-1 [57,4 kB]
Get:2 http://by.archive.ubuntu.com/ubuntu bionic/main amd64 bridge-utils amd64 1.5-15ubuntu1 [30,1 kB]
...
Fetched 68,5 MB in 6s (10,7 MB/s)
Preconfiguring packages ...
Selecting previously unselected package pigz.
(Reading database ... 155677 files and directories currently installed.)
...
Setting up git-man (1:2.17.1-1ubuntu0.7) ...
Setting up runc (1.0.0~rc10-0ubuntu1~18.04.2) ...
Setting up liberror-perl (0.17025-1) ...
Setting up cgroupfs-mount (1.4) ...
Setting up containerd (1.3.3-0ubuntu1~18.04.2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up bridge-utils (1.5-15ubuntu1) ...
Setting up ubuntu-fan (0.12.10) ...
Created symlink /etc/systemd/system/multi-user.target.wants/ubuntu-fan.service → /lib/systemd/system/ubuntu-fan.service.
Setting up pigz (2.4-1) ...
Setting up git (1:2.17.1-1ubuntu0.7) ...
Setting up docker.io (19.03.6-0ubuntu1~18.04.1) ...
Adding group `docker' (GID 127) ...
Done.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
docker.service is a disabled or a static unit, not starting it.
Processing triggers for systemd (237-3ubuntu10.39) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
root@host:~#

Check Version

To check the version of docker installed, we will use the --version flag to verify that it was installed.

root@host:~# docker --version
Docker version 19.03.6, build 369ce74a3c
root@host:~#

Add Docker User

If we are not the root user on the system, then we should add our username to the Docker group so that we do not have to add the sudo command every time we run a docker command.

ellen@host:~$ sudo usermod -aG docker ${USER}
ellen@host:~$

To apply these changes to the group, we need to log out and log back in to the server again.

ellen@host:~$ su - ${USER}
Password:
ellen@host:~$

Next, we will ensure our user is added to the Docker group.

ellen@host:~$ id -nG
ellen adm cdrom sudo dip plugdev lpadmin sambashare docker
ellen@host:~$

Test Docker

Now, we will run the hello world docker container to verify that everything is installed and working as expected using the following command.

root@host:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76
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 that 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.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
root@host:~#

As we can see from the command output above, Docker was unable to find the Hello World docker image. Luckily, Docker was smart enough to pull down the missing image and run it. Now, let's try running the command again.

root@host:~# docker run hello-world
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 that 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.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Notice the difference? In the first instance, we waited a few seconds, the second time it started instantly. This is because the first time, docker did not find the image, but went ahead and downloaded it, and then started the program. In the second instance, when we launched the hello-world docker image, the description popped up in the terminal, and nothing happened. This is because, thanks to the run command, we executed the program, it completed its task and ended.

Docker Syntax

The Docker syntax looks like this.

root@host:~# docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Basic Commands

All commands can be found in the Docker documentation, and we will review and analyze some of the most basic ones:

  • run - it creates and starts the container
  • pull - uploads an image from the repository to our computer. `Run` calls this function if the container is not downloaded.
  • ps - view running containers.
  • rm - container removal.
  • stop - stop a running container.
  • start - start a stopped container.
  • exec - execute a command in a running container.
  • cp - copy files between the container and the host system.
  • info - container status and configuration information.
  • logs - container logs.
  • search - image search in the repository.

Docker Command Usage

Now, we will run the docker command utilizing Ubuntu as the software. Once the command completes, we find ourselves within a container console.

root@host:~# docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
d51af753c3d3: Pull complete
fc878cd0a91c: Pull complete
6154df8ff988: Pull complete
fee5db0ff82f: Pull complete
Digest: sha256:747d2dbbaaee995098c9792d99bd333c6783ce56150d1b11e333bbceed5c54d7
Status: Downloaded newer image for ubuntu:latest
root@c6835d3c4e91:/#

Next, we will analyze the flags used in more detail.
-i interactive mode
-t connect to tty console

Let's pay attention to this message.

Unable to find image 'ubuntu:latest' locally

Since we did not specify which version of Ubuntu we want to run, Docker automatically selected the latest version, then downloaded and launched it. The command also created a new console within the newly launched container. We can exit that console using the exit command.

Working With Containers

Uname Command

root@c6835d3c4e91:/# uname -a
Linux c6835d3c4e91 5.3.0-51-generic #44~18.04.2-Ubuntu SMP Thu Apr 23 14:27:18 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@c6835d3c4e91:/#

Enter the uname command in the terminal for the container.
This command shows the information on Ubuntu.

DMesg Command

root@c6835d3c4e91:/# dmesg
dmesg: read kernel buffer failed: Operation not permitted
root@c6835d3c4e91:/#

Now enter the dmesg command. This command allows us to print or manage the kernel ring buffer, however, because we do not have enough rights to output the dmesg command as the user, the operation was not permitted. Although we are logged in as the root user inside the container, the container itself is running as a user who is not allowed to view the kernel log. This clearly demonstrates that the container property is different from the virtual machine.

Exit Command

root@c6835d3c4e91:/# exit
exit
root@ellen-VirtualBox:/home/ellen#

We can exit the container using the exit command.

Run Command

root@host:~# docker run -d -it ubuntu
de84ba80507e71d81034a2eefabdde5d65520d6bee71ec38eb72cee299e7d382
root@host:~#

Next, lets run the docker command using the -d flag
(-d or detached mode = separate mode).

This command was executed and completed. We did not go to the console, but we did receive a list of characters in the output. This set of characters is the actual unique identifier of the container. We can view the working files of the container if we follow the /var/lib/docker/set_our_characters path.

PS Command

Using the ps command, we can see the list of all running containers in the docker engine.

root@host:~# docker ps
CONTAINER ID IMAGE  COMMAND     CREATED       STATUS       PORTS NAMES
de84ba80507e ubuntu "/bin/bash" 3 minutes ago Up 3 minutes awesome_pasteur
root@host:~#

This output shows the following information:

  • CONTAINER ID - this is the first 12 characters of the container identifier. It is necessary to address the container on this id.
  • IMAGE - this is the image type we used for the container.
  • COMMAND - the command is specified when the container starts if we do not specify the command, the default command will be executed.
  • CREATED - the date when the container was first launched.
  • STATUS - shows the status of the container, if it is running, it shows how long it has been working. If stopped, then when did the exit code stopped.
  • PORTS - this parameter refers to the container network. In short, when creating a container, a virtual network interface is created and added to the virtual switch created based on Linux-bridge. We communicate with the container over the network through this virtual grid, We can also forward a container port to the host machine when the container starts. These forwarded ports are reflected in this field. Such port forwarding is convenient because we do not need to know the container's IP address in this virtual grid.
  • NAMES - this is the name of the container. The container has an id, but it is difficult to remember, and therefore we also introduced such a parameter as a name. When the computer is running with a dozen containers, it will be easier to understand by name which belongs to, especially if the containers are running from the same image.

Each time a docker run command is initiated, a new container is created, and no changes are saved inside the old container. When we run docker start, the container is rebuilt from the image with all its layers. Inside the container, we can use the rm -rf command and then restart it, and all the default image files will be in place. But, those files that are created when working in the container will disappear. Docker can forward a folder from the host system to the container so that any changes remain resident and do not go away.

List Running Containers

Now we will list all containers using the -a flag which identifies all the running containers.

root@host:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
de84ba80507e ubuntu "/bin/bash" 58 minutes ago Up 58 minutes awesome_pasteur
c6835d3c4e91 ubuntu "bash" About an hour ago Exited (1) About an hour ago interesting_turing
36d2ad21d7db hello-world "/hello" About an hour ago Exited (0) About an hour ago zen_ganguly
6bbc372dab1f hello-world "/hello" 2 hours ago Exited (0) 2 hours ago vigilant_diffie
root@host:~#

List Stopped Containers

To display a list of containers that are turned off, we enter the docker ps command with the -f flag.

root@host:~# docker ps -a -f status=exited
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c6835d3c4e91 ubuntu "bash" About an hour ago Exited (1) About an hour ago interesting_turing
36d2ad21d7db hello-world "/hello" 2 hours ago Exited (0) 2 hours ago zen_ganguly
6bbc372dab1f hello-world "/hello" 2 hours ago Exited (0) 2 hours ago vigilant_diffie
root@host:~#

The list of containers that are turned off is not very large yet, however, later in our practice, the list can be quite large. To remove a container, we can use the docker rm command. But, using that command will constitute a large amount of manual work, so we will use the docker rm command with the -q flag which will display only the container's id. Then, we can easily select and work with the containers using that command to remove all the containers.

root@host:~# docker rm 
$(docker ps -a -q -f status=exited)
c6835d3c4e91
36d2ad21d7db
6bbc372dab1f
root@host:~#

Now let's look at the list of containers that are turned off using the command:

root@host:~# docker ps -a -f status=exited
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@host:~#

But actually, we still have one running container. We will review it using the docker command with the ps flag.

root@host:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
de84ba80507e ubuntu "/bin/bash" About an hour ago Up About an hour awesome_pasteur
root@host:~#

Attach Command

So, we started this container, but we did not log in to the console. Now we will run the docker command with the attach flag. This command logs us into that running instance.

root@host:~# docker attach awesome_pasteur
root@b089f595d469:/#

Stop Command

Now that we have connected to the console of our running container, we can stop it using the exit command to end it.

root@host:~# docker stop awesome_pasteur
awesome_pasteur
root@host:~#

Search Command

We can use the search command in docker to try to find a specific image we might need. Let's see what kind of MySQL images are available using the search command.

root@host:~# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation... 9484 [OK]
mariadb MariaDB is a community-developed fork of MyS... 3429 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create... 696 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 75
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr... 69
centurylink/mysql Image containing mysql. Optimized to be link... 61 [OK]
deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r... 41 [OK]
bitnami/mysql Bitnami MySQL Docker Image 39 [OK]
tutum/mysql Base docker image to run a MySQL database se... 35
schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup... 30 [OK]
prom/mysqld-exporter 27 [OK]
linuxserver/mysql A Mysql container, brought to you by LinuxSe... 25
centos/mysql-56-centos7 MySQL 5.6 SQL database server 19
circleci/mysql MySQL is a widely used, open-source relation... 19
databack/mysql-backup Back up mysql databases to... anywhere! 17
mysql/mysql-router MySQL Router provides transparent routing be... 15
arey/mysql-client Run a MySQL client from a docker container 14 [OK]
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image... 6
fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas... 6 [OK]
genschsa/mysql-employees MySQL Employee Sample Database 5 [OK]
devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici... 3
ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 2 [OK]
jelastic/mysql An image of the MySQL database server mainta... 1
widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl... 0 [OK]
monasca/mysql-init A minimal decoupled init container for mysql 0
root@host:~#

Now, If we need a mysql image of version 5.6 for CentOS 7, then we select centos / mysql-56-centos7. We can install the image from the repository without launching it.

root@host:~# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
54fec2fa59d0: Pull complete
bcc6c6145912: Pull complete
951c3d959c9d: Pull complete
05de4d0e206e: Pull complete
319f0394ef42: Pull complete
d9185034607b: Pull complete
013a9c64dadc: Pull complete
42f3f7d10903: Pull complete
c4a3851d9207: Pull complete
82a1cc65c182: Pull complete
a0a6b01efa55: Pull complete
bca5ce71f9ea: Pull complete
Digest: sha256:61a2a33f4b8b4bc93b7b6b9e65e64044aaec594809f818aeffbff69a893d1944
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
root@host:~#

Start Command

Next, we can start the MySQL container.

root@host:~# docker run -it mysql
2020-05-11 19:33:55+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-11 19:33:55+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-05-11 19:33:55+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-11 19:33:56+00:00 [ERROR] [Entrypoint]: 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
root@host:~#

Nothing happened, but we were given a hint!

2020-05-11 19:33:56+00:00 [ERROR] [Entrypoint]: 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

We can either set the root password to access the database ourselves or entrust the script to do it for us. It is also possible to prohibit or allow empty passwords. This is done using variables that are written in an uppercase hint. To set a password, we would use the following command.

root@host:~# docker run --name Project1.MySQL -e MYSQL_ROOT_PASSWORD=ellen -P -d mysql
10de0d398748a27da0ba19e5b55b11600aee9c52f4f5f35a7d693bb2deeea641
root@host:~#

Here is a breakdown the flags we used in that command.

  • --name: this flag creates a database name when creating a container
  • -e or environment: - with this flag we set the password variable when the container starts
  • -P: this flag is responsible for forwarding a port from the container to the host machine. Using the upper case flag randomly gives port forwarding. If we need a specific one, we do it like this -p 2222: 22 this flag published the host port, then the container port.
  • -d: this flag runs the container in background and prints the container ID

Since we have a database name, we can find the MySQL port of our container is using.

root@host:~# docker port Project1.MySQL
3306/tcp -> 0.0.0.0:32771
33060/tcp -> 0.0.0.0:32770
root@host:~#

One other important point; The port forwarding parameter (from the virtual machine to the host machine) starts with the address 0.0.0.0. This means that the port is displayed on the host machine on all network interfaces and accepts requests from everyone.

Logging Command

Now we will use the following log command within the container, which is very useful for diagnosis.

root@host:~# docker logs Project1.MySQL

2020-05-11 19:38:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.

2020-05-11 19:38:12+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'

2020-05-11 19:38:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.

2020-05-11 19:38:12+00:00 [Note] [Entrypoint]: Initializing database files

2020-05-11T19:38:12.637104Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2020-05-11T19:38:12.637221Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.20) initializing of server in progress as process 42

2020-05-11T19:38:12.652198Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

2020-05-11T19:38:17.463918Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

2020-05-11T19:38:20.230586Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password! Please consider switching off the --initialize-insecure option.

2020-05-11 19:38:29+00:00 [Note] [Entrypoint]: Database files initialized

2020-05-11 19:38:29+00:00 [Note] [Entrypoint]: Starting temporary server

2020-05-11T19:38:29.485259Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2020-05-11T19:38:29.485431Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 89

2020-05-11T19:38:29.521148Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

2020-05-11T19:38:30.889054Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

2020-05-11T19:38:31.216916Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock'

2020-05-11T19:38:31.709888Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2020-05-11T19:38:31.740322Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.

2020-05-11T19:38:31.778124Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.20' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.

2020-05-11 19:38:31+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.

2020-05-11 19:38:40+00:00 [Note] [Entrypoint]: Stopping temporary server

2020-05-11T19:38:40.110433Z 10 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.20).

2020-05-11T19:38:42.043063Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.

2020-05-11 19:38:42+00:00 [Note] [Entrypoint]: Temporary server stopped

2020-05-11 19:38:42+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.

2020-05-11T19:38:42.462522Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2020-05-11T19:38:42.462711Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1

2020-05-11T19:38:42.496840Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

2020-05-11T19:38:44.141457Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

2020-05-11T19:38:44.452387Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

2020-05-11T19:38:44.620529Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2020-05-11T19:38:44.642722Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.

2020-05-11T19:38:44.692891Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.20' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.

root@host:~#

(Note: we have added spacing to improve viewing)

Inspect Command

The following command will display the detailed configuration of the running container. Here we can see everything related to the MySQL docker container. Note: This will output a LARGE amount of data.

root@host:~# docker inspect Project1.MySQL
[
{
"Id": "10de0d398748a27da0ba19e5b55b11600aee9c52f4f5f35a7d693bb2deeea641",
"Created": "2020-05-11T19:38:09.822005568Z",
"Path": "docker-entrypoint.sh",
"Args": [
"mysqld"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 12026,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-05-11T19:38:12.042161194Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:a7a67c95e83189d60dd24cfeb13d9f235a95a7afd7749a7d09845f303fab239c",
"ResolvConfPath": "/var/lib/docker/containers/10de0d398748a27da0ba19e5b55b11600aee9c52f4f5f35a7d693bb2deeea641/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/10de0d398748a27da0ba19e5b55b11600aee9c52f4f5f35a7d693bb2deeea641/hostname",
"HostsPath": "/var/lib/docker/containers/10de0d398748a27da0ba19e5b55b11600aee9c52f4f5f35a7d693bb2deeea641/hosts",
"LogPath": "/var/lib/docker/containers/10de0d398748a27da0ba19e5b55b11600aee9c52f4f5f35a7d693bb2deeea641/10de0d398748a27da0ba19e5b55b11600aee9c52f4f5f35a7d693bb2deeea641-json.log",
"Name": "/Project1.MySQL",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"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,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": true,
"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,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/3882aacffce3543db691b71ca4e475b8ce3b52be69b52600bac2776547d77002-init/diff:/var/lib/docker/overlay2/f4a9198e2b09aa276a470ac4eb5f500590c89e3628552a8cb46c4e5e0260d102/diff:/var/lib/docker/overlay2/c4adca2b3163496e2ac04a6b023c41c50f8dfddfbe966f3fd2dcf1d19d3629f8/diff:/var/lib/docker/overlay2/6c50572970f7e9a0241d21ba2ac105a3e90cf734c5f3325119834b268cccc2a1/diff:/var/lib/docker/overlay2/ec5aab1f09c7eed68399363afd202d3e1b991a856c8527003ae497c9b37b80bb/diff:/var/lib/docker/overlay2/321d286ec329f8ed36f6fedfa65387c9ad3a6de5d192d27e1cd43a9efc0ea003/diff:/var/lib/docker/overlay2/6393fe5f99f7bb6ef798d5e7e69add3572f545a5a58d6dfc7f745caedcf5d91b/diff:/var/lib/docker/overlay2/2e26a48961ce5ea41f1104e838c77d86648667623f4e3364433ddcbd286df594/diff:/var/lib/docker/overlay2/10e04f695a94d89a58c8464524adab3262202c0e66db4b32d21ce407148523d2/diff:/var/lib/docker/overlay2/1d8c025d18d1a55b317a464552f0e834c5c21a4abfa3e5983489a43eb648f3e7/diff:/var/lib/docker/overlay2/93e34d1d135455553370c57fbe79355661ac605eb9936ed6246c766bb6687c71/diff:/var/lib/docker/overlay2/09115b618288a320f7d0dab773a6f2824d7a832b6844532824c42f0c3f36be3a/diff:/var/lib/docker/overlay2/9385e9e66b48468eba82867e9b8783ae2362688e8be153e850e8360dc75ddc70/diff",
"MergedDir": "/var/lib/docker/overlay2/3882aacffce3543db691b71ca4e475b8ce3b52be69b52600bac2776547d77002/merged",
"UpperDir": "/var/lib/docker/overlay2/3882aacffce3543db691b71ca4e475b8ce3b52be69b52600bac2776547d77002/diff",
"WorkDir": "/var/lib/docker/overlay2/3882aacffce3543db691b71ca4e475b8ce3b52be69b52600bac2776547d77002/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "7b2e8ee4837513ecc3bbc03803b542611975622ad5a2f39352457560717010fd",
"Source": "/var/lib/docker/volumes/7b2e8ee4837513ecc3bbc03803b542611975622ad5a2f39352457560717010fd/_data",
"Destination": "/var/lib/mysql",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "10de0d398748",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"MYSQL_ROOT_PASSWORD=ellen",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.12",
"MYSQL_MAJOR=8.0",
"MYSQL_VERSION=8.0.20-1debian10"
],
"Cmd": [
"mysqld"
],
"Image": "mysql",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "526463f58f908b63569038509da04fb0d5813ff0d56db591434ddbd496c71913",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "32771"
}
],
"33060/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "32770"
}
]
},
"SandboxKey": "/var/run/docker/netns/526463f58f90",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "10c8b1b0f62439d05ea147b6139d6a8302f4555eec071cbb02327d969dda6f0d",
"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": "e93127c6d3efe1360f68a9e0c1da0ec7d4c9619ef8a9f4a689ecb3f30d4ecc5c",
"EndpointID": "10c8b1b0f62439d05ea147b6139d6a8302f4555eec071cbb02327d969dda6f0d",
"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
}
}
}
}
]
root@host:~#

Conclusion

In this tutorial, we learned what docker containerization is, how it works and why it is now used by almost every large firm that relies on a stable platform. Docker uses virtualization to provide software packages found in containers. These containers are detached from each another so that if one part of a system fails, it does not affect the rest of the system. It also can kick up a new docker image to replace the failed container almost instantly, which limits downtime and increases the overall stability of the system. These containers bundle all the software, libraries and configuration files needed to run the software. Additionally, the containers can communicate with each other through defined networks. Overall, Docker provides saves time, money and precious resources.

Would you like more information about setting up Docker on your existing server or within a new cluster? Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions or Experienced Hosting advisors to learn how you can take advantage of these techniques today!

Avatar for Ellen Sletton

About the Author: Ellen Sletton

I'm 23 years old Linux Tech who always takes NO as Next Opportunity. Every day I'm trying to learn something new and share my knowledge with others. My free time I spend with my dog Emil or doing some UI/UX design or simply making an inspiring photo for my blog :) Sharing knowledge helps me generate new ideas and stay motivated.

Latest Articles

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article