Reputation: 8837
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.
Upvotes: 27
Views: 49907
Reputation: 323
In addition to the mentioned answers, you can use uname -v
as well to determine the OS version.
docker rum <image-name> uname -v
an example of that would be
docker run alpine uname -v
#78~20.04.1-Ubuntu SMP Wed Oct 9 22:05:22 UTC 2024
Upvotes: 0
Reputation: 181
To get the OS details for the specific docker image, please execute the below commands
$ docker exec -it container_name bash
$ cat /etc/os-release
Upvotes: 0
Reputation: 364
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
Upvotes: 33
Reputation: 1
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/"
Upvotes: 0
Reputation: 99
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
. . .
Upvotes: 5
Reputation: 1033
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
Upvotes: 10
Reputation: 32156
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
Upvotes: 3
Reputation: 10664
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
Upvotes: 1