Fix Docker Sources in Ubuntu After Upgrade

- 2 min read

After upgrading to Ubuntu 19.04 Disco from 18.04 Bionic I found that my Docker CE sources were incorrect and had to manually fix them.

Follow this guide if you’re looking for instructions on how to install Docker on Ubuntu.

I found out I had a problem when I ran sudo apt update and was informed:

W: Skipping acquire of configured file 'stable/source/Sources' as repository 'https://download.docker.com/linux/ubuntu bionic InRelease' does not seem to provide it (sources.list entry misspelt?)

Remove old Docker packages

First, find out what old packages you have for Docker:

dpkg -l | awk '$2 ~ /docker/{print $2"\t"$3}'

The command above performs a regular expression match for “docker” but only searches in the second column of dpkg -l's output. It then only prints matching lines’ second and third columns, which is the information relevant to our needs.

I received:

docker-ce	5:18.09.6~3-0~ubuntu-cosmic
docker-ce-cli	5:18.09.6~3-0~ubuntu-cosmic

If you don’t know your version of Ubuntu’s codename you can run lsb_releases -cs.

This means I have two packages installed “docker-ce” and “docker-ce-cli” that are for the Ubuntu Cosmic (18.10) package.

Next, remove the packages:

sudo dpkg -P docker-ce-cli docker-ce

-P purges configuration along with the removed application. If you wish to keep your configuration, use -r instead.

Remove old Docker sources

Next edit “/etc/apt/sources.list” to remove old sources lists (you’ll need to use sudo and your favorite editor).

I found the following lines at the bottom of my configuration file:

deb [arch=amd64] https://download.docker.com/linux/ubuntu cosmic stable # disabled on upgrade to cosmic
deb-src [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

I commented out both of them by prefixing them with #:

# deb [arch=amd64] https://download.docker.com/linux/ubuntu cosmic stable # disabled on upgrade to cosmic
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

Now my sudo apt update runs cleanly without any warning for Docker.

Install Docker

Now that you’ve cleaned up your old packages/sources, you should re-install the latest Docker on Ubuntu.