lsb_release: command not found in latest Ubuntu Docker container

LinuxDockerUbuntuContainersVersion

Linux Problem Overview


I just wanted to test something out real quick. So I ran a docker container and I wanted to check which version I was running:

$ docker run -it ubuntu    
root@471bdb08b11a:/# lsb_release -a
bash: lsb_release: command not found
root@471bdb08b11a:/# 

So I tried installing it (as suggested here):

root@471bdb08b11a:/# apt install lsb_release
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package lsb_release
root@471bdb08b11a:/# 

Anybody any idea why this isn't working?

Linux Solutions


Solution 1 - Linux

It seems lsb_release is not installed.

you can install it via

apt-get update && apt-get install -y lsb-release && apt-get clean all

Hope that helps ;)

Solution 2 - Linux

This error can happen due to uninstalling or upgrading the default python3 program version in ubuntu 16.04

The way to correct this is by reinstalling the original python3 version which comes with ubuntu and relinking again. (in ubuntu 16.04 - the default python3 version is python 3.5

sudo rm /usr/bin/python3
sudo ln -s /usr/bin/python3.5 /usr/bin/python3

Solution 3 - Linux

lsb_release.py lives in /usr/share/pyshared which to me doesn't look like python3.6 and above is referencing.

I found the following will create a link back from a later Python install to ths /usr/share script:

sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python3.9/site-packages/lsb_release.py

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionkramer65View Question on Stackoverflow
Solution 1 - LinuxckasererView Answer on Stackoverflow
Solution 2 - LinuxMagnus MelwinView Answer on Stackoverflow
Solution 3 - LinuxJulian RobbinsView Answer on Stackoverflow