Where do UBUNTU_CODENAME and / or VERSION_CODENAME come from?

In these directions for installing the Docker Engine https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository, an example script is provided and beneath it the comment "If you use an Ubuntu derivative distro, such as Linux Mint, you may need to use UBUNTU_CODENAME instead of VERSION_CODENAME.".

As I’m using Xubuntu I thought that perhaps I would need to alter the script to use UBUNTU_CODENAME but when I tried echo $UBUNTU_CODENAME and echo $VERSION_CODENAME there was no output from either .

Do these env vars need to be initialized in some way ?

enter image description here

Asked By: glaucon

||

The variables UBUNTU_CODENAME and VERSION_CODENAME are set by sourcing the file /etc/os-release in the command from the link you provided:

echo 
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu 
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | 
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Look at the third line of the snippet, the file /etc/os-release is sourced and then the variable VERSION_CODENAME is echoed.

Take a look at /etc/os-release:

~$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
Answered By: mook765