I am just retaking Docker after a long time last used it and I noticed those two variants over Docker Hub where you can either pick from programming language only images (like node:11) and programming language plus linux distro image (like node:11-alpine), so I wonder what the difference is between those two at runtime, I mean, the programming language only images will rely on the host OS to run? or I must always download images with an included OS to make it run properly?
-
1For node images, they offer an explanation in the **Image Variants** section of their dockerhub page: https://hub.docker.com/_/node. Most popular ones also do as well (ex. python images). – Gino Mempin Jan 14 '21 at 23:45
-
That's right, but I still unsure of what happens if I just pull the node image without a OS, wonder if stills work – Diego Serrano Gómez Jan 14 '21 at 23:51
-
3Try it :) It's usually built some Linux distro as base, or as the case for node, it's "*based off of buildpack-deps*". If it doesn't specify anything, it usually is for users who don't care what's the base image or what the resulting size/layers will be. They just want to get their app running. – Gino Mempin Jan 15 '21 at 00:12
-
2Couldn't you figure this out yourself just by downloading one of the images and seeing what it contains? – Ken White Jan 15 '21 at 01:39
-
1@GinoMempin I just got it tested yesterday, as you suggest any image seems to have a base Debian image, thanks a lot for encouranging me to try it by myself – Diego Serrano Gómez Jan 16 '21 at 21:09
1 Answers
Let's clear up some of the confusion using the node
Docker images.
When you do docker pull
of some node:version
that does not have a -linux-distro
prefix, it does not mean that it does not have an OS (or a working environment) and that only the "images with an included OS" will run properly. It usually just means that you, as a user of this image, don't care what the base image is or what the base Linux distro is, and that you just want to containerize your working app as quickly as possible without doing extra work (ex. extra stuff to install, etc.).
If you look at the Supported tags and respective Dockerfile links section for node images, you'll see that node:version
images are still just aliases of a particular node:version-linux-distro
. For example, for node:14.15.4
:
If you try to pull them, they refer to the same image:
~$ docker pull node:14.15.4
14.15.4: Pulling from library/node
2587235a7635: Pull complete
953fe5c215cb: Pull complete
....
Digest: sha256:04a33dac55af8d3170bffc91ca31fe8000b96ae1bab1a090deb920ca2ca2a38e
Status: Downloaded newer image for node:14.15.4
docker.io/library/node:14.15.4
~$ docker pull node:14.15.4-stretch
14.15.4-stretch: Pulling from library/node
Digest: sha256:04a33dac55af8d3170bffc91ca31fe8000b96ae1bab1a090deb920ca2ca2a38e
Status: Downloaded newer image for node:14.15.4-stretch
docker.io/library/node:14.15.4-stretch
Both node:14.15.4
and node:14.15.4-stretch
have the same digest
04a33dac55af8d3170bffc91ca31fe8000b96ae1bab1a090deb920ca2ca2a38e
...and they also are both generated from the same Dockerfile. You can also try comparing the layers:
~$ docker inspect --format='{{.RootFS}}' node:14.15.4 > node.14.15.4.txt
~$ docker inspect --format='{{.RootFS}}' node:14.15.4-stretch > node.14.15.4-stretch.txt
~$ diff --brief node.14.15.4.txt node.14.15.4-stretch.txt
...and there's no difference. If you still think that the node:14.15.4
has no OS, run it and check:
~$ docker run -it node:14.15.4 bash
root@942ea36068d9:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/
~$ docker run -it node:14.15.4-stretch bash
root@d504a57244eb:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
...and see that they node:14.15.4
is also built with Debian Stretch as its base image (technically it's buildpack-deps:stretch
if you check the Dockerfile).
This applies to other "programming language" images, like ruby
and python
. So, to answer your question, there shouldn't be any difference when you use the image with no specified Linux distro. It's for people who don't want to care what Linux distro was used, and wants something usable right away.
The more relevant question with images like these that have Linux distro's in their names is "Which Linux distro should I use?".
For node
images, it's explained in the Image Variants section of their Dockerhub page. Quoting the one for node:<version>
, (the one without a Linux distro):
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.
...
This tag is based off of buildpack-deps. buildpack-deps is designed for the average user of Docker who has many images on their system. It, by design, has a large number of extremely common Debian packages. This reduces the number of packages that images that derive from it need to install, thus reducing the overall size of all images on your system.
Note the part about having many packages already pre-installed. Usually, this means that if you are not building and publishing your own app images based on this image, or if you are not concerned about the resulting size of your images (ex. disk space is not an issue), or if you don't have a CI/CD pipeline that pulls and pushes the image to/from somewhere, then you can always start with this type of image.
The -alpine
and the -slim
are typically when you want to reduce the size of your images, but they typically require a lot more work to install stuff you need (stuff that was pre-installed in other images). Again see the Image Variants section for explanation why and when you need them. You can also check this related SO post: In Docker image names what is the difference between Alpine, Jessie, Stretch, and Buster?.

- 25,369
- 29
- 96
- 135
-
1Such a great and elaborated explanation, many thanks for your response, it makes me a lot clearer idea of how docker containers work behind the scenes I will go try it by myself to keep learning deeper on this, is a very interesting technology and complex one, I think couldn't make it in time without community help – Diego Serrano Gómez Jan 16 '21 at 21:12