Install Docker in Ubuntu 18

This article describes how to install Docker CE in Ubuntu 18.04 LTS. Follow the steps below to install Docker in Ubuntu 18 using the repository, or you can refer the official Docker Docs for other options.

Docker is a popular container platform. Visit the official Docker website for more info: https://www.docker.com/

How to install Docker

  1. Launch a new terminal window

  2. First, make sure apt supports HTTPS:

    sudo apt-get update
    
    sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
    
  3. Add Docker’s GPG key:

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

    docker gpg key add command

  4. Enter the below to get the latest stable docker repository:

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

    docker get repository

  5. Now we can install Docker with the following commands:

    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io
    
  6. Finally, verify the installation by running the hello-world image:

    sudo docker run hello-world
    

    The hello-world image will not exist, so Docker will download it then run it. You should see something like the below:

    docker hello world