How to install Docker on Debian?

I want to install Docker on Debian 9.
When I adding Docker repositories to APT sources,

Commands are:
sudo add-apt-repository “deb [arch=amd64] Index of linux/debian/ $(lsb_release -cs) stable”

appear:
Traceback (most recent call last):
File “/usr/bin/add-apt-repository”, line 95, in
sp = SoftwareProperties(options=options)
File “/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py”, line 109, in init
self.reload_sourceslist()
File “/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py”, line 599, in reload_sourceslist
self.distro.get_sources(self.sourceslist)
File “/usr/lib/python3/dist-packages/aptsources/distro.py”, line 93, in get_sources
(self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for ALT/stretch

Why did this happen?
Can anyone help me, please?

It looks like the output of lsb_release -cs on your system is ALT/stretch for some reason, but that’s not the name of a dist in the docker repository. Edit your /etc/apt/sources.list and find the line for download.docker.com and change ALT/stretch to stretch.

Edit: Just realized that error is probably coming from add-apt-repository so the line isn’t even getting added to your config yet. Try sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/debian stretch stable"

1 Like

Debian 9? Stretch? Which is really old, and towards the end of the LTS lifecycle too.

1 Like

Thank you very much for answering my question!
But I don’t see download.docker.com in /etc/apt/sources.list

And I tried the command, but still appear:
aptsources. Distro. NoDistroTemplateException: Error: Could not find a distribution template for ALT/ Stretch.