0

Docker images can inherit from other images. Therefore, using the official Python docker image allows running Python applications and tools.

docker run --rm -it python bash

After creating and running an interactive container from the python image, I would like to print the Linux distribution information.

lsb_release

However, the lsb_release command is not found. According to the documentation, it used the Debian distribution as the base image. How can I get the exact distribution information?

Péter Szilvási
  • 362
  • 4
  • 17
  • Your Docker image is probably built `FROM` a fixed base, and a typical setup will `RUN` installation commands for any external OS commands that are needed, so when your application runs you should know exactly what's there. Is there a reason you need to look this up dynamically? Also see [Check Linux distribution name](https://stackoverflow.com/questions/2756737/check-linux-distribution-name) if the application needs to run in several environments and the distribution name specifically matters. – David Maze Apr 26 '23 at 13:22

1 Answers1

1

The latest Python image supports different operating systems and architectures. Find OS/ARCH information by releases at https://hub.docker.com/_/python/tags. Click on a specific DIGEST link for more information.

The official Ubuntu Docker image does not have lsb_release. An alternative command to retrieve the distribution information:

cat /etc/os-release

reference: https://serverfault.com/questions/476485/do-some-debian-builds-not-have-lsb-release

Péter Szilvási
  • 362
  • 4
  • 17
  • I'll just add that for a Python image, at the interactive Python shell, you can quickly check the same info with `import subprocess; _ = subprocess.run("cat /etc/*release", shell=True)` – nigh_anxiety Apr 26 '23 at 14:23