Instal Docker Ubuntu

Estimated reading time: 12 minutes

To get started with Docker CE on Ubuntu, make sure youmeet the prerequisites, theninstall Docker.

Next, execute the following commands to upgrade apt index and then install Docker on Ubuntu 20.04 Linux system. Sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io After successful installation of Docker community edition, the service will start automatically, Use below command to verify service status. Step-4: Refreshing package index and Installing Docker apt packages. Now finally, it's time to install Docker. But first, we will need to refresh our package index as well. Sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io Step-5: Testing Docker. Now that we have installed Docker, let us test it and give it a try. Ubuntu is a Debian-based Linux operating system that runs from the desktop to the cloud, to all your internet connected things. It is the world's most popular operating system across public clouds and OpenStack clouds. It is the number one platform for containers; from Docker to Kubernetes to LXD, Ubuntu can run your containers at scale. Jul 09, 2021 Step 1) Install prerequisites packages for docker. Login to Ubuntu 20.04 /20.10 system and run the following apt commands to install docker dependencies, $ sudo apt update $ sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common.


Docker EE customers

Install docker ubuntu 18.04 server

To install Docker Enterprise Edition (Docker EE), go toGet Docker EE for Ubuntuinstead of this topic.

To learn more about Docker EE, seeDocker Enterprise Edition.

OS requirements

To install Docker CE, you need the 64-bit version of one of these Ubuntuversions:

  • Bionic 18.04 (LTS)
  • Artful 17.10
  • Xenial 16.04 (LTS)
  • Trusty 14.04 (LTS)

Docker CE is supported on Ubuntu on x86_64, armhf, s390x (IBM Z), and ppc64le (IBM Power) architectures.

ppc64le and s390x limitations: Packages for IBM Z and Power architectures are only available on Ubuntu Xenial and above.

Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these areinstalled, uninstall them:

It’s OK if apt-get reports that none of these packages are installed.

The contents of /var/lib/docker/, including images, containers, volumes, andnetworks, are preserved. The Docker CE package is now called docker-ce.

Supported storage drivers

Docker CE on Ubuntu supports overlay2 and aufs storage drivers.

  • For new installations on version 4 and higher of the Linux kernel, overlay2is supported and preferred over aufs.
  • For version 3 of the Linux kernel, aufs is supported because overlay oroverlay2 drivers are not supported by that kernel version.

If you need to use aufs, you need to do additional preparation asoutlined below.

Extra steps for aufs

For Ubuntu 16.04 and higher, the Linux kernel includes support for OverlayFS,and Docker CE uses the overlay2 storage driver by default. If you needto use aufs instead, you need to configure it manually.See aufs

Unless you have a strong reason not to, install thelinux-image-extra-* packages, which allow Docker to use the aufs storagedrivers.

Install Docker CE

You can install Docker CE in different ways, depending on your needs:

  • Most usersset up Docker’s repositories and installfrom them, for ease of installation and upgrade tasks. This is therecommended approach.

  • Some users download the DEB package andinstall it manually and manageupgrades completely manually. This is useful in situations such as installingDocker on air-gapped systems with no access to the internet.

  • In testing and development environments, some users choose to use automatedconvenience scripts to install Docker.

Install using the repository

Before you install Docker CE for the first time on a new host machine, you need toset up the Docker repository. Afterward, you can install and update Docker fromthe repository.

Set up the repository

  1. Update the apt package index:

  2. Install packages to allow apt to use a repository over HTTPS:

  3. Add Docker’s official GPG key:

    Verify that you now have the key with the fingerprint9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for thelast 8 characters of the fingerprint.

  4. Use the following command to set up the stable repository. You alwaysneed the stable repository, even if you want to install builds from theedge or test repositories as well. To add the edge ortest repository, add the word edge or test (or both) after theword stable in the commands below.

    Note: The lsb_release -cs sub-command below returns the name of yourUbuntu distribution, such as xenial. Sometimes, in a distributionlike Linux Mint, you might need to change $(lsb_release -cs)to your parent Ubuntu distribution. For example, if you are using Linux Mint Rafaela, you could use trusty.

    Note: Starting with Docker 17.06, stable releases are also pushed tothe edge and test repositories.

    Learn about stable and edge channels.

Install Docker CE

  1. Update the apt package index.

  2. Install the latest version of Docker CE, or go to the next step to install a specific version:

    Got multiple Docker repositories?

    If you have multiple Docker repositories enabled, installingor updating without specifying a version in the apt-get install orapt-get update command always installs the highest possible version,which may not be appropriate for your stability needs.

  3. To install a specific version of Docker CE, list the available versions in the repo, then select and install:

    a. List the versions available in your repo:

    b. Install a specific version by its fully qualified package name, which is package name (docker-ce) “=” version string (2nd column), for example, docker-ce=18.03.0~ce-0~ubuntu.

    The Docker daemon starts automatically.

  4. Verify that Docker CE is installed correctly by running the hello-worldimage.

    This command downloads a test image and runs it in a container. When thecontainer runs, it prints an informational message and exits.

Docker CE is installed and running. The docker group is created but no usersare added to it. You need to use sudo to run Docker commands.Continue to Linux postinstall to allownon-privileged users to run Docker commands and for other optional configurationsteps.

Upgrade Docker CE

To upgrade Docker CE, first run sudo apt-get update, then follow theinstallation instructions, choosing the new version you wantto install.


Install from a package

If you cannot use Docker’s repository to install Docker CE, you can download the.deb file for your release and install it manually. You need to downloada new file each time you want to upgrade Docker CE.

  1. Go to https://download.docker.com/linux/ubuntu/dists/,choose your Ubuntu version, browse to pool/stable/ and choose amd64,armhf, ppc64el, or s390x. Download the .deb file for the Dockerversion you want to install.

    Note: To install an edge package, change the wordstable in the URL to edge.Learn about stable and edge channels.

  2. Install Docker CE, changing the path below to the path where you downloadedthe Docker package.

    The Docker daemon starts automatically.

  3. Verify that Docker CE is installed correctly by running the hello-worldimage.

    This command downloads a test image and runs it in a container. When thecontainer runs, it prints an informational message and exits.

Docker CE is installed and running. The docker group is created but no usersare added to it. You need to use sudo to run Docker commands.Continue to Post-installation steps for Linux to allownon-privileged users to run Docker commands and for other optional configurationsteps.

Upgrade Docker CE

To upgrade Docker CE, download the newer package file and repeat theinstallation procedure, pointing to the new file.

Install using the convenience script

Docker provides convenience scripts at get.docker.comand test.docker.com for installing edge andtesting versions of Docker CE into development environments quickly andnon-interactively. The source code for the scripts is in thedocker-install repository.Using these scripts is not recommended for productionenvironments, and you should understand the potential risks before you usethem:

  • The scripts require root or sudo privileges to run. Therefore,you should carefully examine and audit the scripts before running them.
  • The scripts attempt to detect your Linux distribution and version andconfigure your package management system for you. In addition, the scripts donot allow you to customize any installation parameters. This may lead to anunsupported configuration, either from Docker’s point of view or from your ownorganization’s guidelines and standards.
  • The scripts install all dependencies and recommendations of the packagemanager without asking for confirmation. This may install a large number ofpackages, depending on the current configuration of your host machine.
  • The script does not provide options to specify which version of Docker to install,and installs the latest version that is released in the “edge” channel.
  • Do not use the convenience script if Docker has already been installed on thehost machine using another mechanism.

This example uses the script at get.docker.com toinstall the latest release of Docker CE on Linux. To install the latesttesting version, use test.docker.com instead. Ineach of the commands below, replace each occurrence of get with test.


Always examine scripts downloaded from the internet beforerunning them locally.


Docker CE is installed. It starts automatically on DEB-based distributions. OnRPM-based distributions, you need to start it manually using the appropriatesystemctl or service command. As the message indicates, non-root users can’trun Docker commands by default.

Upgrade Docker after using the convenience script

If you installed Docker using the convenience script, you should upgrade Dockerusing your package manager directly. There is no advantage to re-running theconvenience script, and it can cause issues if it attempts to re-addrepositories which have already been added to the host machine.

Uninstall Docker CE

  1. Uninstall the Docker CE package:

  2. Images, containers, volumes, or customized configuration files on your hostare not automatically removed. To delete all images, containers, andvolumes:

You must delete any edited configuration files manually.

Next steps

  • Continue to Post-installation steps for Linux

  • Continue with the User Guide.

requirements, apt, installation, ubuntu, install, uninstall, upgrade, update

Docker doesn’t need any introduction now, it is a popular and free-to-use container solution that has established itself very well in the field of container-based applications. Here we will learn the best way to install Docker on Ubuntu Hirsute 21.04, Ubuntu Groovy 20.10, Ubuntu Focal 20.04 (LTS), and Ubuntu Bionic 18.04 (LTS).

Being a containerized software solution, Docker offers all functions needed to virtualize applications and operate the containers in an isolated environment from one another, on a host system. A container contains all the resources required to run an application, including the application code, the runtime environment, the system libraries, and the system tools. The system which manages the computer’s resources to the individual containers and ensures their isolation on the host system is called Docker Engine.

Few key advantages of using Docker container machines:

  • Free to use Software
  • It requires fewer resources than virtual machines
  • Scalability
  • Provides Security and isolates the applications from one another and from the host system
  • Lightweight
  • Simple management of many containers via orchestration tools such as Kubernetes
  • The availability of containers in the image file makes it easily transferrable to other systems.
  • Easy to install and Quickstart


  • Best method to install Docker on Ubuntu 20.04 Linux

Best method to install Docker on Ubuntu 20.04 Linux

There are three ways to install Docker on Ubuntu Linux but the best one is by using its official repository. Whereas the two others are SNAP and the base repo.

Hence, here we will show the steps to set up Docker on Ubuntu by adding its official repository which is the best possible way to get the latest stable version. Of course, we can get it via SNAP but due confinement model of Snap you may get issues in connecting to the Docker daemon. Or the system would not be able to recognize the docker daemon running on the host. On the other side, the Docker installation from Ubuntu’s base repo will be an extremely stable one, no doubt, but with no guarantee, you will get the latest one with all new features. Hence, go for the tutorial given below:

1. Add few common packages

There are few packages we require during the setup of Docker on Ubuntu such as adding its repo over HTTPS need package that supports it, curl, and lsb-release to know the version of Linux.

2. Add Docker’s GPG Key

Before adding the repository of Docker, we have to add the GPG key that will ensure the packages we will get to install Docker, are from the authentic source without any kind of alteration.

3. Best way- Add Stable Docker repository on Ubuntu 20.04 or others

Now, on your Ubuntu, paste the following block of command and hit Enter key. It will automatically detect your Ubuntu version to add the corresponding available repository.

4. Run system update

To let the system know that we have recently added a new repository, run a system update command to rebuild the system repo cache.

5. Install Docker Engine on Ubuntu

Install Docker Ubuntu 14

Finally, run a single command that will install and set up the Docker community version with other required tools on your Ubuntu 20.04 Linux or the one you are using.

6. Test your installation

To know everything has been installed correctly to work with containers, let’s create a simple container image called hello-world.

7. Add your User to the Docker group

By default, to create any Container or to run the Docker command you have to use sudo with it. To remove this, we need to add our current to its group.

Reload group

Install Docker Ubuntu 20

That’s it, now the latest version of Docker is on your respective Ubuntu version. From here you can start exploring and creating containers by pulling from DockerHub or creating your own image.

Install Docker Linux

If you are not comfortable with the command line then try out the Docker GUI, here is the article on it: Install Portainer Docker Web GUI or How to install Kitematic on Ubuntu 20.04 LTS…

Most Viewed Posts