-1

I am trying to verify When choosing a Docker container image file for my Ubuntu, what do I need to match between them?

On Lubuntu, a CentOS container says it is CentOS, by

$ sudo docker run centos bash -c "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) 

but also says it is the same Ubuntu as the host:

$ sudo docker run centos bash -c "cat /proc/version"
Linux version 4.15.0-46-generic (buildd@lgw01-amd64-038) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019


$ cat /proc/version
Linux version 4.15.0-46-generic (buildd@lgw01-amd64-038) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019
  1. I wonder why the two commands differ in OS distribution and kernel version?

  2. Does a container share the same kernel as its host? If yes, should their kernel versions be the same? When choosing a Docker container image file for my Ubuntu, what do I need to match between them? says "you don't need to match distributions or kernel versions."

  • 2
    So you’ve asked a question, been given an answer, which you’ve accepted, but you don’t believe it? – Stephen Kitt Apr 5 at 17:34
  • I want to verify if a container and its host must have the same version of kernel, since they are said to share the same Linux kernel. I am not sure how to understand his comment. – Tim Apr 5 at 17:46
  • 1
    Have you looked at the resources I suggested here? I think that would help you understand all this better. – Stephen Kitt Apr 5 at 18:24
  • 2
    "Does a container share the same kernel as its host? If yes, should their kernel versions be the same?" Don't you even read your own post? – 炸鱼薯条德里克 Apr 5 at 23:41
3

cat /proc/version is showing kernel version. As containers run on the same kernel as the host. It is the same kernel as the host.

cat /etc/*-release is showing the distribution release. It is the OS version, minus the kernel.

A container is not virtualisation, in is an isolation system that runs directly on the Linux kernel. It uses the kernel name-spaces, and cgroups. Name-spaces allow separate networks, process ids, mount points, users, hostname, Inter-process-communication. cgroups allows limiting resources.

3
  1. I can't find in the provided output the CentOS Kernel info, only the version release (7.6.1810);
  2. Yes, the container shares the kernel of the host machine.

Update: Check this answer.

  • I don't understand the first point: It does not look like an answer, but I can't tell for sure, as it does not look like a sentence. – ctrl-alt-delor Apr 6 at 9:08
  • My (possibly incorrect) interpretation is that JucaPirama looked for a "differ(ence) in OS distribution and kernel version" and did not see any indication of a different kernel version in the /etc/release output. – Jeff Schaller Apr 6 at 12:11
  • English is not my mother language, so let me try again: I could not find in the cat /etc/*-release output nothing concerning Kernel Version (because it is not there). So, the question itself makes no sense. – JucaPirama Apr 8 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.