Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker container isolation, does it care about underlying Linux OS?

Tags:

If I run Docker Engine and the same container on a set of different Linux distributions, will the container run in the same way? I am asking because in many cases applications depend on a specific Linux distribution for some resources, such as fonts. If my application running inside a Docker container depends on a font used in Ubuntu (and there may be many other dependencies), how is this managed? Will I need to install the font inside container, will I need to run Ubuntu inside the container running the application, or does the application use fonts from the underlying OS running the container?

like image 484
user1340582 Avatar asked Apr 28 '15 05:04

user1340582


People also ask

Does Docker use underlying OS?

Each container shares the services of one underlying operating system. Docker images contain all the dependencies needed to execute code inside a container, so containers that move between Docker environments with the same OS work with no changes.

Are Docker containers based on Linux?

The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

Does host OS matter for containers?

Since containers share the host OS, they do not need to boot an OS or load libraries. This enables containers to be much more efficient and lightweight. Containerised applications can start in seconds and many more instances of the application can fit onto the machine as compared to a VM scenario.

How does Docker isolation work?

Docker uses a technology called namespaces to provide the isolated workspace called the container. When you run a container, Docker creates a set of namespaces for that container. These namespaces provide a layer of isolation.


2 Answers

Any missing resources should be installed in a Docker image (which can start from the ubuntu image).
It should not rely on host for dependencies.

The idea is to be able to reproduce the environment each time a container is run from an image.

A container don't see the host resources (beside mounted volumes), since it has the Docker engine between the container and the host, in order to configure cgroups and namespaces to control which resources the container can see and access.

Docker

The "fedora" image referenced in jboss/base is the base image:

images

In Docker terminology, a read-only Layer is called an image. An image never changes.

Since Docker uses a Union File System, the processes think the whole file system is mounted read-write. But all the changes go to the top-most writeable layer, and underneath, the original file in the read-only image is unchanged.
Since images don't change, images do not have state.

See "What is the relationship between the docker host OS and the container base image OS?":

The only relationship between the host OS and the container is the Kernel.

as the kernel is still the kernel of the host, you will not have any specific kernel module/patches provided by the distribution.

like image 66
VonC Avatar answered Oct 05 '22 00:10

VonC


What you need to be careful is

  • the kernel dependency,
  • and some mandatory access control (SELinux, Apparmor) configurations, which are distribution dependent and may have an impact on how your Docker containers work.
like image 39
xuhdev Avatar answered Oct 05 '22 00:10

xuhdev