Reputation: 569
I'm starting a new Django Project using Docker. I'm confused about the existence of the Ubuntu Docker image which is mentioned in many tutorials as well as being one of the most popular images in the Docker Repo.
I thought Docker is a containerization system built ON TOP of the OS, so why is there an Ubuntu Docker Image? Perhaps a common use scenario on when/who would use this would help.
Upvotes: 8
Views: 2399
Reputation: 74680
With a Linux distro you normally get:
init
system that sets up and runs everything elseDocker itself replaces most of the init
system.
Docker images replace "Everything else", which can still be a large portion of any normal distro.
An Ubuntu image contains the minimal set of Ubuntu binaries and shared libraries compiled with the Ubuntu build tools to run a shell, do some normal linuxy things and use the apt
package manager.
A Centos image does the same with Centos binaries, shared libraries and the yum
package manager. etc.
A Docker image doesn't need to be a complete distribution. You can run a single statically compiled binary in a container and you only need that binary in the image, nothing else.
The busybox image is a good example of building a largely normal Linux environment from a single static binary.
All containers share the one host kernel. The container is separated from the rest of the system using kernel cgroups and namespaces. To anything running in the container, this appears to be it's own system.
All flavours of Linux don't use the exact same kernel but the kernel interfaces are largely compatible which allows the portability of Docker images. Docker itself requires a 3.10+ kernel to be able to run which narrows the range of kernel possibilities.
It's possible to have some esoteric software that requires some esoteric kernel feature to be compiled in, that wouldn't run across different Docker hosts. That's pretty rare and usually identifiable as it would often require a custom kernel compile or kernel modules to get said software working in the first place.
Upvotes: 13
Reputation: 17261
You can create your own image from scratch. Literally your Dockerfile would start like this
FROM: scratch
...
but then everything that is needed to run your program needs to be added to the image. That's why it's more typical to start from a lightweight base linux image like Alpine (very small at just 5MB) or Debian/Ubuntu (126MB) that already have base tools/services needed by your app. You want to try to keep your final image small.
Upvotes: 3
Reputation: 368231
It is the other way around -- Docker really is 'just a process on steroids'.
The question then is: "which" process. Having Docker containers for each of the different Ubuntu releases allows you to, for example, tests with the different Django versions shipped with each.
Illustration using the Ubuntu images I have here and bash --version
:
$ docker run --rm -ti ubuntu:trusty bash --version | head -1
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
$ docker run --rm -ti ubuntu:vivid bash --version | head -1
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
$ docker run --rm -ti ubuntu:wily bash --version | head -1
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
$ docker run --rm -ti ubuntu:xenial bash --version | head -1
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
$
Upvotes: 2