This guide will explain how to install Docker CE on Ubuntu and Ubuntu Server 20.04

The version of Docker in the default Ubuntu repository is not the latest and will not function correctly therefore we must add the official Docker repository and install the latest version

1. Remove Previous Versions of Docker

If you previously had Docker installed from the default Ubuntu repository you must remove it with the following command:

sudo apt-get remove docker docker-engine docker.io containerd runc -y

2. Install Dependency’s

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    network-manager \
    software-properties-common -y

3. Add Docker GPG Key and Official Repository

To add the GPG Key type:

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

To add the repository type the command:

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

Then

sudo apt-get update

Now you are ready to install Docker

4. Install Docker

Assuming you have followed all previous instructions correctly you should now be able to install Docker with the command:

sudo apt-get install docker-ce docker-ce-cli containerd.io -y

5. Test your Docker Install (Optional)

To test your docker install run the hello-world script:

sudo docker run hello-world

If Docker is working correctly the following message will be displayed:

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 which 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/

Post Installation Steps

Install Portainer (Optional)

Portainer allows you to view and manage all the Docker containers on your system.

To install Portainer simply paste or type this command into your terminal:

docker run -d \
-p 9000:9000 \
--restart always \
--name Portainer \
-v /opt/portainer-data:/data \
-v /var/run/docker.sock:/var/run/docker.sock portainer/portainer

Now you should be able to access Portainer from:

http://your.ip.address.here:9000

2 Replies to “Install Docker on Ubuntu 20.04”

Leave a Reply

Your email address will not be published. Required fields are marked *