Which OS is running in my Docker container?

Most of the time, using one of these two, I can tell which OS is running in my Docker container (alpine, centOS, etc)

But this time, I can't tell:

bash-4.2$ uname -a       
Linux 6fe5c6d1451c 2.6.32-504.23.4.el6.x86_64 #1 SMP Tue Jun 9 20:57:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

bash-4.2$ more /etc/issue
\S
Kernel \r on an \m

Any way to get a text version of the OS it is running ?

I like to use Screenfetch. You might want to try that.

If you look into the code you can see how it determines the distribution:

  • lsb_release -sirc
  • cat /etc/os-release

And to cover CentOS too:

  • cat /etc/issue

uname will tell you the kernel that's running, which is the host OS kernel (containers, unlike VM's, share the same kernel).

To identify the base image of the container, there's no guaranteed solution from inside the container. You can look for pointers from the major vendors like Janosch gives (/etc/os-release for most vendors like Debian, CentOS and Alpine, or /etc/lsb-release for Ubuntu). You can also check the package management tools if they are installed (/etc/apk, /etc/apt, /etc/yum).

Outside of the container, you can inspect the image and track down the layers to see where the image comes from, but that gets into locating sha256 checksums. The best method is to review the Dockerfile that was used the build the image.

On a docker trimmed container, this worked for me after no luck with /etc/release, /etc/issue, lsb_release, etc. (I know some are for specific Distros):

Execute this command as root:

# cat /proc/version
Linux version 4.19.121-linuxkit (root@18b3f92ade35) (gcc version 9.2.0 (Alpine 9.2.0)) #1 SMP Thu Jan 21 15:36:34 UTC 2021

SOURCE: https://unix.stackexchange.com/questions/23833/how-can-i-tell-what-version-of-linux-im-using/326917#326917