...but every one of them needs your Linux kernel.
Disclaimer 1: before going any further it's important to understand the difference between a kernel, an operating system, and a distribution.
Linux kernel is the core part of the Linux operating system. It's what originally Linus wrote.
Linux operating system is a combination of the kernel and a user-land (libraries, GNU utilities, config files, etc).
Linux distribution is a particular version of the Linux operating system like Debian, CentOS, or Alpine.
Disclaimer 2: the title of this article should have sounded like "Not every container has whole Linux distribution in it". But I personally find this wording a bit boring 🤪
Does a Container have an Operating System inside?
The majority of Docker examples out there explicitly or implicitly rely on some flavor of the Linux operating system running inside a container. I tried to quickly compile a list of the most prominent samples:
Running an interactive shell in the debian jessie
distribution:
$ docker run -it debian:jessie
Running an nginx
web-sever in a container and examine its config using cat
utility:
$ docker run -d -P --name nginx nginx:latest
$ docker exec -it nginx cat /etc/nginx/nginx.conf
Building an image based on Alpine Linux:
$ cat <<EOF > Dockerfile
FROM alpine:3.7
RUN apk add --no-cache mysql-client
ENTRYPOINT ["mysql"]
EOF
$ docker build -t mysql-alpine .
$ docker run mysql-alpine
And so forth and so on...
For the newcomers learning the containerization through hands-on experience, this may lead to a false impression that containers are somewhat indistinguishable from full-fledged operating systems and that they are always based on well-known and wide-spread Linux distributions like debian
, centos
, or alpine
.
Read more