3

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.

2

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.

5
  • Do you know if the base python image (EX: Python-3.7) does not have a Linux Distribution? – Renan Cunha Nov 5 '19 at 17:34
  • @RenanCunha according to the page on Docker Hub, that tag points to 3.7.5-buster for Linux hosts. You can follow the tags and FROM lines in the Dockerfiles linked by each tag. – BMitch Nov 5 '19 at 18:51
  • 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) – Tensibai Nov 6 '19 at 22:01
  • @Tensibai I'm listing commands that many will recognize. These tend to be the most familiar for each respective group. – BMitch Nov 6 '19 at 22:49
  • Yep, I jus the felt the need to be a bit pedantic :) – Tensibai Nov 6 '19 at 22:57
2

Your docker image could be without an OS, that's called distroless image.

https://docs.docker.com/develop/develop-images/baseimages/

https://github.com/GoogleContainerTools/distroless

4
  • Do you know if the base python image is this case? – Renan Cunha Nov 5 '19 at 15:54
  • @RenanCunha : there is many base python images (from your link), they are all OS based images (*buster are Debian based, *alpine are Alpine based...) – sebthebert Nov 5 '19 at 19:52
  • That's a stretch, first command is installing an OS, and it has to be compatible with your docker host kernel... – Tensibai Nov 6 '19 at 21:54
  • In brief distroless != osless, you still have an OS, with the basic libraries, you just avoid the "base utilities" (shell, editor, etc.), you still need core libraries like glibc unless your app is totally statically linked (and then you just need to create your image FROM scratch) – Tensibai Nov 6 '19 at 22:05
0

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.

2
  • For example, on the Python 3.6.9 It lists the OSs/ARCHs. This is the OS/ARCH that the container run or that it has? – Renan Cunha Nov 5 '19 at 16:52
  • @RenanCunha: I don't understand your question. This is listing the OS/ARCH that the image uses. You do not need to have that that installed on your system as the OS and all the dependencies are "contained" in the image. If you remoted into the container this is the OS that you would see. – Wesley Rolnick Nov 5 '19 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.