Hi,
I’m a newbie to Docker and Linux. Following this training and many others I see that you can run a “centos” container on a Ubuntu Linux OS.
How is this possible? The way I am seeing containers would contain applications and its dependencies. Please explain how is it that a container runs another OS?
Before going further please understand I’m a “windows guy”.
Can you explain what happens when you run a container from a CentOS image inside an Ubuntu for example? Or is the kernel for most Linux OS distributions the same and what distinguishes them is just the processes and applications installed over the kernel? So when I run a CentOS docker container all its doing is just running the apps processes that make CentOS different from others?
Exactly, a Linux kernel is inside every Linux distro. RedHat/CentOS 7.2 ships with a kernel version 3.10, while Ubuntu 16.04 ships with 4.4, but you can usually upgrade the kernel since it’s backward compatible.
When you run a CentOS7 container on docker it runs that distro but uses the kernel of the docker server.
$ docker run centos:7 uname -a
Linux b3f0a5f004d1 4.4.0-36-generic ...
The binaries available in that container, and the yum package management, are all the same as if you installed CentOS7 on a real machine.
PS: speaking of confusing… I’m not sure what “containers running Windows” means exactly, but it’s coming and sounds interesting:
I have my base application in SLES SP3. Now we are thinking to dockerizing the application. The thing is, the base version we are shifting to is RedHat Linux. Could you please clarify below questions :
Does the Docker Engine in RHEL is free ?
If we install Docker Engine in RHEL, Shall we go for my SLES application ported to CentOS and create CentOS image running on RHEL Docker ?
Or we port SLES application to RHEL and create RHEL image itself running on RHEL docker engine?
Which would be more easy and cost effective (The cost is coming considering RHEL is coming under Docker EE). If Docker Engine in RHEL is free of cost, then Option 2 is suits much, right ?
A year or two ago, Docker barely ran on CentOS 6 at all. Its Linux kernel is ancient by Docker’s standards, and so you’re dependent on some specific patches being back ported a long long way. I’d really try to upgrade the host, especially if you are trying to use Docker and the application’s runtime environment is isolated from the host’s.
If you can get Docker running, there’s no reason a CentOS 7 based image would work better or worse than any other distro (or no distro at all).
David,
Thanks for the info. Yes unfortunately we stuck on centos 6.8 for the moment.
$ uname -r
2.6.32-642.15.1.el6.x86_64
$ docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
OS/Arch (client): linux/amd64
I am just curious, if the guest kernel is at 3.10 host is at2.6, will it work? I know the other way around will work because of the backward compatibility.
@jamshid : U said that the containerized OS uses the docker server’s kernel. Then how does an ubuntu container run on a windows machine when the docker server (windows) does not even have a linux kernel to support ubuntu?
On Windows or other non Linux OS the docker installer also installs a virtual machine on which the docker engine will be running. That VM has a linux kernel.
The docker engine effectively runs on a virtualized host, not directly on Windows/MacOS.
Hi Dmaze, you misunderstood kknd2222.
He wants to know, for Linux host and guests: can the guest’s kernel be an older version than the host?
for instance:
version of host kernel is N;
version of guest is N+1 or N+0.1.
Will that work?