I was following instructions (https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce-1) to try install Docker CE on VirtualBox running Ubuntu 16.04.3. Then when I tried to set up the stable repository on step 4 by doing:

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

I got

Error: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu \ xenial \ stable' invalid

Can someone please help? I am new to programming but online search doesn't appear to show anything directly relevant.


That command is incorrectly line-wrapped which introduces line breaks and backslash characters where there should be none. The correct command would be:

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

However, you still need to find and remove the previously added bogus entries. One way to find the files is via grep:

grep -ne '^deb.*docker.*\\' /etc/apt/sources.list{,.d/*.list}

I assume you know how to edit or remove files owned by root.

  • I started a new virtual machine and its now working! – Redscarfs Dec 27 '17 at 16:19
  • Sad there is actually a question on this. – LUser Nov 3 '20 at 11:44

check the file at /etc/apt/sources.list. The repo line should read:

deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable

Note the lack of backslash. You will need root privileges in order to edit this file if it is incorrect.

  • Corrected, THX! – Redscarfs Dec 27 '17 at 16:18

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" this errored for me CICD with -- deb invalid.

Then changed to , add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable' worked for me. (that is, changed " to ')

  • There is nothing in the quoted portion that would be treated differently with the different quotes. Perhaps when you used double quotes they were not standard double quotes, but fancy ones (i.e. a different unicode character) copy-pasted from somewhere? – Zanna Nov 6 '20 at 1:55

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.