How to install Docker on Ubuntu 18.04

H

Docker is a tool designed to facilitate the creation, deployment, and execution of apps using containers. It helps users create an isolated and regulated app system but also to add all its dependencies for an independent workflow.

Compared to other virtual machines systems, Docker has the advantage of being based on a container virtualization system.

Unlike a regular virtual machine, Docker allows apps to use the Linux kernel of the host system and to free the data buffer from processes that are already running on the host machine. This gives a significant boost to the container performance of and reduces application size.

Docker provides a set of tools such as Docker Engine, Docker Compose, Docker Hub, Docker Swarn, Docker Machine, and Docker Trusted Registry. Each of these tools comes with different commands.

What do we need in order to install Docker on Ubuntu 18.04?

1) A machine installed with Ubuntu Server 18.04
2) An account on the Docker Hub platform

How-to install Docker

First, you update the system software and repositories:

sudo apt update

Then you need to install the following dependencies:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Set the password to the Docker deposit located on your machine:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker repository to your APT sources file:

sudo add-apt-repository "deb [arch = amd64] https://download.docker.com/linux/ubuntu bionic stable"

Update the system software and repositories once again with software from the Docker repository:

sudo apt update

Check and ensure yourself that the data you are going to download comes from the Docker repository, not from the default Ubuntu repository:

apt-cache policy docker-ce

The following text will be generated, but the version number can be more recent:

The output of the apt-cache policy docker-ce
Docker-why:
Installed: (none)
Candidate: 18.04.2 ~ ~ 2-0 ~ ubuntu
Version table:
18.04.2 ~ ~ 2-0 ~ ubuntu 600
600 https://download.docker.com/linux/ubuntu bionic/stable amd64

Packages

The software used for installation is for Ubuntu 18.04.2 Docker (Bionic)

Afterward, we can install Docker with the following commands:

sudo apt install docker-ce
sudo systemctl status docker

To view Docker data regarding your system, we can input:

docker info

To check what arguments we can use for specific commands, we can use:

docker docker-subcommand --help

Here we will present the most common used Docker commands:

attach We can attach various streams to an active container.
build Generate an image from a Docker file.
commit Build a new image with the changes you made.
cp Copy files and directories from a container to the local machine or viceversa.
Create Generate a new container.
diff See the modifications you have on files and directories on a container.
events Get notified in real time of events on the server.
exec Execute a command in an active container.
export Export the files on a container to a tar archive.
history Show all the modifications made on an image.
images Show images
import Import the content of a tar archive to generate an image.
info Show info regarding the current machine.
inspect Show info regarding Docker objects.
kill Stop a running container.
load Upload an image from a tar archive.
login Login to Docker.
logout Logout from Docker.
logs Download the logs of a container.
pause Stop all processes from containers.
port Show ports for containers.
ps Show a list of containers.
pull Extract an image or a repository from a registry.

Recent Posts

Archives

Categories