I did pull from dockerhub:
docker pull mysql
In its Dockerfile, I see:
FROM debian:stretch-slim
But when I run the container:
sudo docker run -it mysql /bin/bash
And in the container I write the command:
uname -a
and the output is:
Linux 050e1a4b22ed 4.18.0-18-generic #19-Ubuntu SMP Tue Apr 2 18:13:16 UTC 2019 x86_64 GNU/Linux
Why the OS is Ubuntu if the base image in the dockerfile is debian:stretch-slim?
Answer
Docker containers use the kernel of their host, and your host is running an Ubuntu kernel.
Containers are isolated instances created by OS-level virtualization. On Linux, containers run on the kernel of the host, so your container's uname
kernel release and version output is going to be same as the host's.
The host is running Ubuntu 18.04 with kernel release 4.18.0-18-generic, and the OS-level virtualization implementation is LXC (similar to Docker).
deltik@host [~]$ lxc launch -s local images:debian/10 demo
Creating demo
Starting demo
deltik@host [~]$ uname -a
Linux host 4.18.0-18-generic #19~18.04.1-Ubuntu SMP Fri Apr 5 10:22:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Debian 10 Container
deltik@host [~]$ lxc exec demo -- bash
root@demo:~# cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux buster/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@demo:~# uname -a
Linux demo 4.18.0-18-generic #19~18.04.1-Ubuntu SMP Fri Apr 5 10:22:13 UTC 2019 x86_64 GNU/Linux
CentOS 7 Container
deltik@host [~]$ lxc launch -s local images:centos/7 demo
Creating demo
Starting demo
deltik@host [~]$ lxc exec demo -- bash
[root@demo ~]# cat /etc/*-release
CentOS Linux release 7.6.1810 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
CentOS Linux release 7.6.1810 (Core)
CentOS Linux release 7.6.1810 (Core)
[root@demo ~]# uname -a
Linux demo 4.18.0-18-generic #19~18.04.1-Ubuntu SMP Fri Apr 5 10:22:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Gentoo Container
deltik@host [~]$ lxc launch -s local images:gentoo demo
Creating demo
Starting demo
deltik@host [~]$ lxc exec demo -- bash
demo ~ # cat /etc/*-release
Gentoo Base System release 2.6
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo/Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.gentoo.org/"
SUPPORT_URL="https://www.gentoo.org/support/"
BUG_REPORT_URL="https://bugs.gentoo.org/"
demo ~ # uname -a
Linux demo 4.18.0-18-generic #19~18.04.1-Ubuntu SMP Fri Apr 5 10:22:13 UTC 2019 x86_64 Intel(R) Xeon(R) E-2136 CPU @ 3.30GHz GenuineIntel GNU/Linux
No comments:
Post a Comment