1. Why Docker

Docker is an open source container engine that makes it easy to create a lightweight, portable, self-contained container for any application. Containers that developers and system administrators compile and test on laptops can be deployed in batches in production environments, including VMs (virtual machines), Bare Metal, OpenStack clusters, the cloud, data centers, and other basic application platforms. Containers are completely sandboxed and have no interface with each other.

The advantages of using a Docker deployment environment on a Linux server are as follows:

  • Easy to build and easy to distribute
  • The isolation application removes dependencies
  • Quick deployment test and sell

Docker is available in enterprise and Community editions. This section describes how to install Docker Engine-Community on a 64-bit Ubuntu18.04 machine.

2. Uninstall the existing docker version in the system

In order to prevent installation errors, you need to check and uninstall the old version of docker, such as docker. IO or docker-engine:

sudo apt-get remove docker docker-engine docker.io containerd runc
Copy the code

If apt-get reports that these packages are not installed, you can do the following:

3. Use the repository to install docker-CE

Before you first install Docker engine-Community on a new host, you need to set up the Docker repository. After that, you can install and update Docker from the repository.

Set up the Docker repository

Update apt package index:

sudo apt-get update
Copy the code

Install the following packages to enable APT to use the repository over HTTPS:

sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Copy the code

Add Docker official GPG key:

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

Verify that you now have a key with a fingerprint by searching for the last 8 characters of the fingerprint:

sudo apt-key fingerprint 0EBFCD88
Copy the code



Use the following command to set up stable repositories:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Copy the code

Install the Docker – ce

Update apt package index:

sudo apt-get update
Copy the code

Docker Engine-Community and Containerd

sudo apt-get install docker-ce docker-ce-cli containerd.io
Copy the code

Test Docker – ce

Once installed, you can verify that Docker engine-community is properly installed by running the Hello-world image:

sudo docker run hello-world
Copy the code

This command downloads the test image and runs it in the container. When the container runs, it prints a reference message and exits.

Docker Engine-Community is installed and running. The Docker group has been created but no users have been added, so you need to run the Docker command using sudo.

More examples can be found at: docs.docker.com/get-started… .

Upgrade Docker – ce

Update the index:

sudo apt-get update
Copy the code

Then reinstall the steps:

sudo apt-get install docker-ce docker-ce-cli containerd.io
Copy the code

Uninstall the Docker – ce

Uninstalling Docker Engine

sudo apt-get purge docker-ce
Copy the code

Images, containers, volumes, or custom profiles on the host are not automatically deleted. To delete all images, containers and volumes:

sudo rm -rf /var/lib/docker
Copy the code