Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between ubuntu and and an ubuntu docker image?

Tags:

linux

docker

With docker it seems like it's possible to run multiple OS's on the same machine for example

docker run -it ubuntu:latest
root@09e498dae658:/#

docker run -it centos:latest
[root@8216b5141efc /]# 

The docker docs state that the Linux Kernel comes from the host running the linux container. So for the above command I get same output when I run cat /proc/version

docker run -it ubuntu:latest
root@09e498dae658:/# cat /proc/version
Linux version 4.9.87-linuxkit-aufs (root@95fa5ec30613) (gcc version 6.4.0 (Alpine 6.4.0) ) #1 SMP Wed Mar 14 15:12:16 UTC 2018

docker run -it centos:latest
[root@8216b5141efc /]# cat /proc/version
Linux version 4.9.87-linuxkit-aufs (root@95fa5ec30613) (gcc version 6.4.0 (Alpine 6.4.0) ) #1 SMP Wed Mar 14 15:12:16 UTC 2018

Since the Kernel is the same same regardless of what image is used it seems quite wrong to think of docker as being able to run multiple OS's on the same machine. Some questions.

  • When executing docker run -it ubuntu:latest what parts of ubuntu are there and what parts are missing? Can it be considered Ubuntu?

  • If the Kernel is the same regardless of what images are used what's the point of actually using a specific os container image like ubuntu:latest or centos:latest?

  • Is there a mechanism/process used to ensure that the os packages are compatible with the Kernel used the docker host?

  • Is it a best practice to run a container image on a kernel of the same type for example run ubuntu:latest on host that has the same version of ubuntu as the container image?

like image 961
ams Avatar asked May 27 '18 11:05

ams


People also ask

What is the Ubuntu Docker image?

The official Ubuntu Docker image is the most downloaded image from Docker Hub. With over one billion downloads, Ubuntu has proven itself to be a popular and reliable base image on which to build your own custom Docker images.

What is an image in Ubuntu?

Images are built from a model assertion using ubuntu-image, a tool to generate a bootable image. It can be installed on a snap-supporting Linux system as follows: $ sudo snap install ubuntu-image --classic. The ubuntu-image command needs only the filename of the model assertion to build an image.

Why do we need Ubuntu for Docker?

If you app is compiled to run on Linux, it relies on Linux libraries (libc, glib, and so on) that must be present in executing environment, regardless of its type. Docker makes no exception to this. So a Ubuntu application requires a Ubuntu image in order to run correctly.

What is a Docker image?

A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker container, like a template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM) environments.


1 Answers

You're right, the kernel will be the same. However, the distro is the collection of software included with the kernel, so when running centos vs ubuntu in a container, you're just getting access to whatever packages are included with ubuntu. The most apparent difference to me would be the default package manager (yum vs apt).

  • The default software packages will be there. Since the software packages and file structure are two things that are part of what describes a distro, yes I think you could call it Ubuntu.
  • The point of using a specific os image is to get access to the default packages, package manager, design choices used, and behavior on top of the kernel.
like image 146
Mulli Avatar answered Nov 01 '22 23:11

Mulli