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

16.04dockersoftware installation

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) \
   stable"

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.

Best Answer

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.

Related Question