Lsb_Release: Command Not Found in Latest Ubuntu Docker Container

lsb_release: command not found in latest Ubuntu Docker container

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

lsb_release of the host OS in a Docker

LSB is kind of deprecated/ignored on Debian-based distributions, and the file is not present in the Docker images of the most popular distros.

/etc/os-release is prefered now. You can see that this file is present on the Docker images of a lot of distributions (even Alpine), which is not the case with /etc/lsb-release.

lsb-release has no installation candidate while trying to install on Ubuntu 20.04.3 LTS

From my machine:


$ apt policy lsb-release
lsb-release:
Installed: 11.1.0ubuntu2
Candidate: 11.1.0ubuntu2
Version table:
*** 11.1.0ubuntu2 500
500 http://in.archive.ubuntu.com/ubuntu focal/main amd64 Packages
500 http://in.archive.ubuntu.com/ubuntu focal/main i386 Packages
100 /var/lib/dpkg/status

The package lsb-release comes from the repository main. The output of sudo apt update suggests that you've missing sources in your sources.list file.

To investigate further, I started a new docker container and disabled all instances of the main repository and I was able to reproduce this issue. You can fix this issue by following the below steps:

  1. You must enable the main repository in order to install the package lsb-release:

    sudo add-apt-repository main

    I highly recommend you to enable the Universe repository too:

    sudo add-apt-repository universe
  2. Run apt update after enabling the repositories:

    sudo apt update
  3. If I'm seeing the output correctly, you have one more issue with the package manager, as stated in this answer remove the offending files with:

    sudo rm -rf /etc/apt/apt.conf.d/20snapd.conf
  4. Install lsb-release again:

    sudo apt install lsb-release

The package lsb-release should be installed now.

How do I install os specific packages inside docker?

This should work

RELEASE=$(cat /etc/lsb-release  | grep DISTRIB_RELEASE  | cut -d= -f2)

I just tried it on my ubuntu:latest docker image and got version 16.04

$ docker run -it ubuntu:latest /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
6d28225f8d96: Pull complete
166102ec41af: Pull complete
d09bfba2bd6a: Pull complete
c80dad39a6c0: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:5718d664299eb1db14d87db7bfa6945b28879a67b74f36da3e34f5914866b71c
Status: Downloaded newer image for ubuntu:latest

And here is the output

root@9c4c1e6313ce:/# RELEASE=$(cat /etc/lsb-release  | grep DISTRIB_RELEASE  | cut -d= -f2)
root@9c4c1e6313ce:/# echo $RELEASE
16.04

Docker installation problem (ubuntu 20.04 LTS) - E: The repository 'https://download.docker.com/linux/ubuntu \ Release' does not have a Release file

Make sure the content of the /etc/apt/sources.list.d/docker.list corresponds to the output of the command in the documentation, bullet #3.

At the time of this writing executing the command on my Ubuntu 20.04 LTS results in the following content of the docker.list file:

deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable

which seems to be different from that of yours.

Cannot install packages inside docker Ubuntu image

It is because there is no package cache in the image, you need to run:

apt-get update

before installing packages, and if your command is in a Dockerfile, you'll then need:

apt-get -y install curl

To suppress the standard output from a command use -qq. E.g.

apt-get -qq -y install curl

Problem installing Docker Ubuntu, step related to command pub (Ubuntu 18.04)

Instead of installing from the repository, why don't you try doing it directly.

sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker

If this works, you will notice it only works with sudo the workaround for this issue is mentioned here

Let me know if this doesn't work! I'm also quite confused as to why your errors include RabbitMQ when you are trying to install docker on ubuntu?



Related Topics



Leave a reply



Submit