Does every container have an OS?
For example, the base docker python image has a default OS in it? I couldn't find any info on Google.
I am in doubt because there are some images made with Python that use the Alpine OS.
DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure. It only takes a minute to sign up.
Sign up to join this communityDoes every container have an OS?
For example, the base docker python image has a default OS in it? I couldn't find any info on Google.
I am in doubt because there are some images made with Python that use the Alpine OS.
The python image is based on Debian, Alpine, or Windows Core depending on which tag you select. E.g. if you click on the tag for one of the buster images, you see the Dockerfile with a FROM buildpack-deps:buster
entry. Going to that repo on Docker Hub you can track it back to FROM buildpack-deps:buster-scm
, then FROM buildpack-deps:buster-curl
, and finally FROM debian:buster
.
It's important to note that these are not really operating systems, they are Linux distributions that have their filesystems packaged into a container filesystem. You are not managing devices or even running the kernel of that operating system, only using their tools (e.g. apt-get
, yum
, or apk
) to manage the contents of the container.
It is possible to have a container without any Linux distribution as it's base. Every image eventually goes back to FROM scratch
which is a meta image name that indicates an empty filesystem. It's the same as the filesystem after rm -rf /
or format c:
, completely empty, no files, no shell to run, no libraries. If you have a statically linked application without any dependencies on the rest of the filesystem, it's possible to deploy with this in a container since the host Linux kernel is what's actually running the application (docker is just a way to applications on the host with isolation (namespaces) and limits (cgroups) preconfigured). An example of this can be found with the Docker doodles. And building on scratch is Google's distroless images which include various prereqs that many need when running in a container without a distribution included.
3.7.5-buster
for Linux hosts. You can follow the tags and FROM lines in the Dockerfiles linked by each tag.
rm -rf /
and format c
: are not the same thing, one empty the existing filesystem where the second create a filesystem. a rmdir /s /q C:
would be a better analogy IMHO. (Never tested trying to format from a windows container, but I assume it would have the same access denied as a fdisk in a linux container trying to modify the host devices)
Your docker image could be without an OS, that's called distroless image.
FROM scratch
)
By default there is some sort of OS driving almost every container. If you look at the tags tab on the docker python image you asked about you can see the OS that the image uses.
Alpine has become a very popular base for docker containers as it is extremely small. On the same tags tab compare the 3.5 tagged image at 344.58 MB to the 27.34 MB Alpine image.