31

Why $(uname -a) returns the same Linux kernel than the host machine inside a docker container?

uname -a
#=> Linux leo 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

docker run -ti --rm ubuntu:vivid-20150611 uname -a
#=> Linux 147c3aff216b 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Even though my host machine is Ubuntu 14.04 (trusty) while the container is Ubuntu 15.04 (vivid) and should have kernel 3.19

Leo Gallucci
  • 16,355
  • 12
  • 77
  • 110

2 Answers2

27

Docker uses the host operating system kernel, there is no custom or additional kernel inside the container. All containers running on the machine are sharing this "host" kernel.

See for more information this question on SuperUser.

19
  • cat /etc/os-release, or
  • cat /etc/issue for CentOS

See https://serverfault.com/a/805390/161568.

0 _
  • 10,524
  • 11
  • 77
  • 109
  • 1
    Worked to help figure out debian container as well. – Randolph Jul 02 '18 at 20:42
  • More recent versions of CentOS seem to fill `/etc/os-release` as well: `docker run --rm centos sh -c 'cat /etc/os-release | grep -e "^NAME="'` --> `NAME="CentOS Linux"` – Raphael Jun 11 '20 at 13:53