How to check what OS a docker image depends on?

41.9k Views Asked by At

I want to extend my jenkins image to have docker installed so it can build a Dockerfile out of a project. I found a nice install script for docker but only for Ubuntu 64bit. What I need to know is if the parent images of my jenkins image base on Ubuntu 64bit so I can use this install script without any problems.

I used docker image inspect <imagename> already but it only yields hashes for former image versions it seems.

6

There are 6 best solutions below

3
On BEST ANSWER
docker run <image-name> cat /etc/*release*

It will return the metadata about your image. In the following form.

NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
VARIANT_ID="202011171307-al2.470.0"
Amazon Linux release 2 (Karoo)
cpe:2.3:o:amazon:amazon_linux:2
0
On

The fact that your Jenkins is built on an Ubuntu 64 bits or a Fedora 24 or a Debian jessie should not bother you, as it should work anyway.

See

Run Different Linux OS in Docker Container?

for more explanations

and also

Docker container isolation, does it care about underlying Linux OS?

Anyway, if you want to get the FROM line of the Dockerfile used to build this image,

you can use the docker image

https://hub.docker.com/r/dduvnjak/dockerfile-from-image/

to get the

FROM UBUNTU

or

FROM DEBIAN

example from

How to check for Certain Properties in Docker Images

$ docker run -v /var/run/docker.sock:/var/run/docker.sock dduvnjak/dockerfile-from-image k3ck3c/nethogs | grep FROM

will show

FROM alpine:latest

0
On

I don't think there is currently any docker command that allows you to do that. It seems that the only way is to launch the container and run those commands: determine OS distribution of a docker image

0
On

In the docker world you'll encounter OSes like Alpine more or less frequently. Hence its mostly advisable to get contents of the /etc/os-release file which will in most scenarios be present.

# Tomcat 9 running on Alpine OS
docker run -it tomcat:9-alpine cat /etc/os-release

# Tomcat 9 running Debian (buster)
docker run -it tomcat:9 cat /etc/os-release

docker base os

0
On

Following command worked docker run mysql cat /etc/os-release.

Output:

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
. . .
0
On

Solution: docker run mysql cat /etc/os-release

Output:

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"