config icon indicating copy to clipboard operation
config copied to clipboard

AR-1142 - refactor install_docker to be based on the family

Open jfcabral opened this issue 3 years ago • 2 comments

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

  1. 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
  2. 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

jfcabral avatar Dec 30 '22 01:12 jfcabral

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?

iav avatar Dec 30 '22 03:12 iav

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.

jfcabral avatar Jan 01 '23 22:01 jfcabral