I am trying to install docker on Ubuntu 16.04. I am a complete Ubuntu newbie and only installed it recently.

Here are the installation steps: https://docs.docker.com/engine/installation/linux/ubuntu/

In order to setup the directory, I have to run this command:

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

I am quite confused on what to copy and paste exactly. I first copied and pasted everything from sudo:

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

But I get the following errors:

E: Unable to locate package curl 
E: Unable to locate package apt-transport-https 
E: Unable to locate package ca-certificates 
E: Unable to locate package curl 
E: Unable to locate package software-properties-common

Do you know what those erros mean and what can I do to install Docker properly?

Thank you.

  • thank you for your answer, sorry I forgot to mention that I tried that, as a result I get: 'bash: $: No such file or directory – user2505650 Feb 13 '17 at 21:06
  • Would it be okey to just install it without adding the repository? – M. Becerra Feb 13 '17 at 21:16
  • how would I install it without the repo? and it is clearly mentionned that you need to setup the directory – user2505650 Feb 13 '17 at 21:18
  • 1
    The repository is not the only way to install the program, its handy and simple for later updates though. You can install it following this instructions. – M. Becerra Feb 13 '17 at 21:20

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 \

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


sudo apt-get -y --no-install-recommends install \
  curl \
  apt-transport-https \
  ca-certificates \
  • @user2505650 - I think you should have accepted this answer, not mine. Mine may work, but this one answers exactly and more precisely what you came asking in the first place :) – M. Becerra Feb 15 '17 at 21:42

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.

  • Where did you find this? The official installation instructions (as well as the other sites that talk about docker installation) are way too long, and this script is easy. Should be prominently mentioned in the official docker install instructions instead of all this – DannyB Jul 25 '17 at 9:24
  • @DannyB I had linked to the docker-install repo in my answer. Also see github.com/moby/moby/issues/31514 – Acumenus Jul 25 '17 at 13:15
  • Thanks for this. I hope they opt to update the get.docker.com install script rather than deprecate it, I hate the multi-step installation, and apparently I am not the only one. – DannyB Jul 26 '17 at 14:32

The Docker installation package available in the official Ubuntu repositories may not be the latest version. So I would not suggest to install docker from Ubuntu repositories. To get the latest version, install Docker from the official Docker repository.

For doing this first of all we will add , the GPG key for the official Docker repository to our machine by curl command

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

Now we will add the Docker repository:

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

Update the package database with the Docker packages from the newly added repository

sudo apt-get update

Finally, install Docker by apt-get command

sudo apt-get install -y docker-ce

Docker should now be installed and running. To check whether docker service has been started or not we should run the command sudo service docker status. This will show the status of docker service.


If you want to install on a current Ubuntu, you can simply install the docker.io package via package manager or

sudo apt install docker.io
apt-get update && apt-get install -y \
  apt-transport-https ca-certificates curl software-properties-common gnupg2
  • 3
    How is this command different from other existing answers? – Kulfy Aug 17 '20 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.