Installing Docker on Ubuntu 16.04 - Setting up repository

The command you entered is mostly correct, however, it suffers from a flaw: those \ are supposed to escape newlines, not spaces. The command in the docs is:

$ sudo apt-get install -y --no-install-recommends \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

This should be copy-pasted as-is (except the leading $) or typed in similarly. By removing the newlines, this is what happened:

$ printf "|%s|\n" sudo apt-get -y --no-install-recommends install \ curl \ apt-transport-https \ ca-certificates \ curl \ software-properties-common
|sudo|
|apt-get|
|-y|
|--no-install-recommends|
|install|
| curl|
| apt-transport-https|
| ca-certificates|
| curl|
| software-properties-common|

As you can see, the spaces became part of the package names. That is why apt-get couldn't find them. Do either of:

sudo apt-get -y --no-install-recommends install curl apt-transport-https ca-certificates software-properties-common

Or:

sudo apt-get -y --no-install-recommends install \
  curl \
  apt-transport-https \
  ca-certificates \
  software-properties-common

Installation from a .deb package

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

  • Go to https://apt.dockerproject.org/repo/pool/main/d/docker-engine/ and download the .deb file for the Docker version you want to install and for your version of Ubuntu (latest version 1.13.1 for Ubuntu 16.04).

  • Install Docker, changing the path below to the path where you downloaded the Docker package.

    sudo dpkg -i /path/to/package.deb
    

    The Docker daemon starts automatically.

  • Verify that docker is installed correctly by running the hello-world image.

    sudo docker run hello-world
    

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

Docker is installed and running. You need to use sudo to run Docker commands.


Source: https://docs.docker.com/engine/installation/linux/ubuntu/#install-from-a-package


Although you can set up the repo and install it manually, there is a faster way using the official convenience script.

As of 2018, to install docker-ce on Ubuntu 16.04 or Ubuntu 18.04, the command for the automated install is:

curl https://get.docker.com | sudo sh

Read the security note printed in output toward the end of the install. Note that the script at the URL used above is maintained in the docker-install repo.

This installs the package and the repo. To confirm:

$ apt list docker-ce* 2>&- | grep installed
docker-ce/now 5:18.09.0~3-0~ubuntu-xenial amd64 [installed,local]
docker-ce-cli/now 5:18.09.0~3-0~ubuntu-xenial amd64 [installed,local]

Verify installation:

sudo docker run hello-world
sudo docker version

Continue with post-installation steps.