Introduction on Docker
This article is mainly introducing on how to install docker. The installation process of docker is done in Linux Ubuntu 18.04 Bionic Beaver. Before moving on forward, the introduction of docker is an important thing for specific description. According to several references, one of them has a detail description in this link.
Quoting the definition of docker from that link, Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Furthermore, containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.
Still according to the information on the link, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.
And importantly, Docker is open source. This means that anyone can contribute to Docker and extend it to meet their own needs if they need additional features that aren’t available out of the box.
Steps on Installing Docker in Linux Ubuntu 18.04 Bionic Beaver
Without further description on the docker tool, the following are steps for installing Docker in Linux Ubuntu 18.04 Bionic Beaver. The steps consist of several parts. The first part is the pre-installation part. The next one is the installation part :
Pre-Installation Part of Docker
For the pre-installation part, there are several steps to do. The following are those steps :
1. Switch to root account for docker installation :
user@hostname:~$ sudo su - [sudo] password for user: root@hostname:~#
2. Install several packages where those packages are the pre-requirement for further installation of docker :
root@hostname:~# sudo apt install apt-transport-https ca-certificates curl software-properties-common Reading package lists... Done Building dependency tree Reading state information... Done ca-certificates is already the newest version (20180409). curl is already the newest version (7.58.0-2ubuntu3.5). software-properties-common is already the newest version (0.96.24.32.5). apt-transport-https is already the newest version (1.6.6). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@hostname:~#
3. Add the gpg key for installing docker. This step is important to make the source of the docker installer package is a trust site. Just execute the following command :
root@hostname:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - OK root@hostname:~#
4. The following is the step for adding the site containing docker installer to the Ubuntu repository for further installation :
root@hostname:~# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease Hit:2 http://dl.google.com/linux/chrome/deb stable Release Get:3 https://download.docker.com/linux/ubuntu bionic InRelease [64,4 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [83,2 kB] Hit:6 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic InRelease Get:7 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates InRelease [88,7 kB] Hit:8 http://ppa.launchpad.net/inkscape.dev/stable/ubuntu bionic InRelease Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B] Get:10 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-backports InRelease [74,6 kB] Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [9.400 B] Get:12 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [16,3 kB] Get:13 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/main i386 Packages [393 kB] Get:14 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/main amd64 Packages [443 kB] Get:15 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/main amd64 DEP-11 Metadata [233 kB] Get:16 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/main DEP-11 48x48 Icons [52,2 kB] Get:17 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/main DEP-11 64x64 Icons [99,0 kB] Get:18 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/universe i386 Packages [573 kB] Get:19 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/universe amd64 Packages [577 kB] Get:20 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [194 kB] Get:21 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/universe DEP-11 48x48 Icons [176 kB] Get:22 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/universe DEP-11 64x64 Icons [299 kB] Get:23 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2.468 B] Get:24 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [5.104 B] Ign:25 http://pkg.jenkins.io/debian-stable binary/ InRelease Hit:26 http://pkg.jenkins.io/debian-stable binary/ Release Hit:28 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu bionic InRelease Fetched 3.383 kB in 13s (266 kB/s) Reading package lists... Done root@hostname:~#
5. After adding the docker repository, don’t forget to execute the following command to update the repository :
root@hostname:~# sudo apt update Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease Hit:2 http://dl.google.com/linux/chrome/deb stable Release Hit:3 https://download.docker.com/linux/ubuntu bionic InRelease Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease Hit:6 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic InRelease Hit:7 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-updates InRelease Hit:8 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic-backports InRelease Hit:9 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu bionic InRelease Ign:10 http://pkg.jenkins.io/debian-stable binary/ InRelease Hit:11 http://pkg.jenkins.io/debian-stable binary/ Release Hit:13 http://ppa.launchpad.net/inkscape.dev/stable/ubuntu bionic InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. root@hostname:~#
6. The following is another step for installing docker. This is to check whether the package ‘docker-ce’ has the possibility for further installation or not. It is another way to check whether the package is installed or not. According to the manual page of the apt_preferences, if the target release has not been specified then APT simply assigns priority 100 to all installed package versions and priority 500 to all uninstalled package versions. The command for checking the docker package as follows :
root@hostname:~# apt-cache policy docker-ce docker-ce: Installed: (none) Candidate: 5:18.09.0~3-0~ubuntu-bionic Version table: 5:18.09.0~3-0~ubuntu-bionic 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages 18.06.1~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages 18.06.0~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages 18.03.1~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages root@hostname:~#
According to the output of the above command, the priority number is 500. It means, the package is not installed. Continue on to the next step for the installation part.
Docker Installation Part
The next part is the installation part. After finishing the above steps for the pre-installation, just execute the following steps.
1. So, the next part is the actual installation process of docker. The following is the command execution :
root@hostname:~# apt install docker-ce Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: aufs-tools cgroupfs-mount containerd.io docker-ce-cli pigz The following NEW packages will be installed: aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli pigz 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. Need to get 50,6 MB of archives. After this operation, 243 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic/universe amd64 pigz amd64 2.4-1 [57,4 kB] Get:2 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic/universe amd64 aufs-tools amd64 1:4.9+20170918-1ubuntu1 [104 kB] Get:3 http://xxxxxxxxxxxxxxxxxxxxx/ubuntu bionic/universe amd64 cgroupfs-mount all 1.4 [6.320 B] Get:4 https://download.docker.com/linux/ubuntu bionic/stable amd64 containerd.io amd64 1.2.0-1 [19,9 MB] Get:5 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce-cli amd64 5:18.09.0~3-0~ubuntu-bionic [13,1 MB] Get:6 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce amd64 5:18.09.0~3-0~ubuntu-bionic [17,4 MB] Fetched 50,6 MB in 47s (1.073 kB/s) Selecting previously unselected package pigz. (Reading database ... 278613 files and directories currently installed.) Preparing to unpack .../0-pigz_2.4-1_amd64.deb ... Unpacking pigz (2.4-1) ... Selecting previously unselected package aufs-tools. Preparing to unpack .../1-aufs-tools_1%3a4.9+20170918-1ubuntu1_amd64.deb ... Unpacking aufs-tools (1:4.9+20170918-1ubuntu1) ... Selecting previously unselected package cgroupfs-mount. Preparing to unpack .../2-cgroupfs-mount_1.4_all.deb ... Unpacking cgroupfs-mount (1.4) ... Selecting previously unselected package containerd.io. Preparing to unpack .../3-containerd.io_1.2.0-1_amd64.deb ... Unpacking containerd.io (1.2.0-1) ... Selecting previously unselected package docker-ce-cli. Preparing to unpack .../4-docker-ce-cli_5%3a18.09.0~3-0~ubuntu-bionic_amd64.deb ... Unpacking docker-ce-cli (5:18.09.0~3-0~ubuntu-bionic) ... Selecting previously unselected package docker-ce. Preparing to unpack .../5-docker-ce_5%3a18.09.0~3-0~ubuntu-bionic_amd64.deb ... Unpacking docker-ce (5:18.09.0~3-0~ubuntu-bionic) ... Setting up aufs-tools (1:4.9+20170918-1ubuntu1) ... Setting up containerd.io (1.2.0-1) ... Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service. Processing triggers for ureadahead (0.100.0-20) ... Setting up cgroupfs-mount (1.4) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.9) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Setting up docker-ce-cli (5:18.09.0~3-0~ubuntu-bionic) ... Setting up pigz (2.4-1) ... Setting up docker-ce (5:18.09.0~3-0~ubuntu-bionic) ... update-alternatives: using /usr/bin/dockerd-ce to provide /usr/bin/dockerd (dockerd) in auto mode Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service. Processing triggers for ureadahead (0.100.0-20) ... root@hostname:~#
2. After the installation is actually finished, the following is an additional step for checking the service status :
root@hostname:~# sudo systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2018-11-23 16:41:23; 32s ago Docs: https://docs.docker.com Main PID: 24877 (dockerd) Tasks: 13 CGroup: /system.slice/docker.service └─24877 /usr/bin/dockerd -H unix:// Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.168761810+07:00" level=warning msg="Your kernel does not support swap memory limit" Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.168824696+07:00" level=warning msg="Your kernel does not support cgroup rt period" Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.168841525+07:00" level=warning msg="Your kernel does not support cgroup rt runtime" Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.169568752+07:00" level=info msg="Loading containers: start." Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.329848625+07:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.418470270+07:00" level=info msg="Loading containers: done." Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.538387261+07:00" level=info msg="Docker daemon" commit=4d60db4 graphdriver(s)=overlay2 version=18.09.0 Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.538608965+07:00" level=info msg="Daemon has completed initialization" Nov 23 16:41:23 hostname systemd[1]: Started Docker Application Container Engine. Nov 23 16:41:23 hostname dockerd[24877]: time="2018-11-23T16:41:23.593324090+07:00" level=info msg="API listen on /var/run/docker.sock" root@hostname:~#
3. The next step, it is to modify the user for further docker administration task. It is for adding the specific user executing docker to the ‘docker’ group. Just execute the following command :
root@hostname:~# usermod -aG docker user root@hostname:~# id -nG root root@hostname:~# id -nG user user adm cdrom sudo dip plugdev lpadmin sambashare libvirt docker root@hostname:~#
4. The last step, just execute the following command to start using docker :
user@hostname:~$ docker Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: --config string Location of client config files (default "/home/user/.docker") -D, --debug Enable debug mode -H, --host list Daemon socket(s) to connect to -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") --tls Use TLS; implied by --tlsverify --tlscacert string Trust certs signed only by this CA (default "/home/user/.docker/ca.pem") --tlscert string Path to TLS certificate file (default "/home/user/.docker/cert.pem") --tlskey string Path to TLS key file (default "/home/user/.docker/key.pem") --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Management Commands: builder Manage builds config Manage Docker configs container Manage containers engine Manage the docker engine image Manage images network Manage networks node Manage Swarm nodes plugin Manage plugins secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker trust Manage trust on Docker images volume Manage volumes Commands: attach Attach local standard input, output, and error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container deploy Deploy a new stack or update an existing stack diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information wait Block until one or more containers stop, then print their exit codes Run 'docker COMMAND --help' for more information on a command. user@hostname:~$
2 thoughts on “How to Install Docker in Linux Ubuntu 18.04 Bionic Beaver”