AR-1142 - refactor install_docker to be based on the family
Hi
Motivation This PR was initially motivated by the issue https://armbian.atlassian.net/browse/AR-1142
Upon checking the code, I've noticed it was not exactly as mentioned in the issue https://github.com/armbian/config/blob/c9a9b494c3069807471bb00c0336566cd186f6d9/debian-software#L649 Still, I believe there was yet room for improvement, thus this PR 😄
After reviewing the install_docker function, I've noticed that it is still tied to specific Debian/Ubuntu versions. In my opinion this is not desired, as will require further maintenance in the future, in order to support newer linux versions.
Changes
- I've changed the logic of the referred function so it works based on the linux family, thus following the official docker install guidelines. This will, hopefully, ensure that it will be able to install Docker against any current AND future Debian/Ubuntu versions, without any further changes
- Debian: https://docs.docker.com/engine/install/debian/#install-using-the-repository
- Ubuntu: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
- I've restructured the function code in order to remove some duplicated statements
Tests
Installation of Docker, using the tool on a freshly installed:
- ✅ Ubuntu 22.04.1 (jammy)
- ✅ Ubuntu 18.04.5 (bionic) - proving it is not only forward compatible, but also backwards compatible 😄
Note: In order to speed-up the test process, I've done both tests using WSL2 on Windows 10 (AMD64). I know it's not ideal, but I believe the code, as is, should be independent from the HW architecture.
If you have any question, feedback or suggestion, please do not hesitate to say so :) Thank you
I remember there was an idea "use docker from the default repository for latest releases".
But, maybe, there no need for aptly menu for just apt install docker, and this proposal is a right thing?
Hi @iav, thank you for your feedback!
From my experience, as far as Ubuntu is concerned, you can't simply do an apt-get to install it. Even on the latest LTS version (22.04.1 LTS)
If you were to try to install it, without previously configuring the Docker repository, you'd get this:
# sudo apt-get update was executed right before
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package docker-ce is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'docker-ce' has no installation candidate
E: Unable to locate package docker-ce-cli
E: Unable to locate package containerd.io
E: Couldn't find any package by glob 'containerd.io'
E: Couldn't find any package by regex 'containerd.io'
E: Unable to locate package docker-compose-plugin
tested on a fresh install of Ubuntu 22.04.1 LTS using WSL2 on Windows 10.
So, as far as I know, the "best" way to install docker on Debian/Ubuntu, is by following the official install notes:
- Ubuntu: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
- Debian: https://docs.docker.com/engine/install/debian/#install-using-the-repository
which involves setting up the repository.
There's also the possibility of using an official convenience script: https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script but since the repository strategy was already implemented, I've decided to stick to it.