Which Operating System is Docker virtualizing when it runs the Node image? - node.js

When you use the Node Docker Image, i suppose that Docker is running or (virtualizing) a OS that has a node installation, I will like to know what is that OS, or how is posible that Docker is able to run NodeJs

There are several different image variants for Node - the official builds are all either flavors of Debian or Alpine Linux.
See more information: https://github.com/nodejs/docker-node/blob/main/README.md#image-variants
node:<version>
Debian
node:alpine
Alpine
node:buster
Debian 10
node:stretch
Debian 9
node:slim
Debian minimal

Related

How to use node LTS version in alpine:3.17 image?

I'm using alpine 3.14 docker image. In the release info it is said, there is node LTS (18) and current (19) included.
How do I use the LTS version of node, which is 18.20?
FROM alpine:3.17#sha256:c0d488a800e4127c334ad20d61d7bc21b4097540327217dfab52262adc02380c
RUN apk --update add bash curl git npm
Using this container, the current node version is used.
The Alpine OS distribution is different from the Alpine docker containers. The alpine container images do not include node. In fact, most of the packages listed on the page you link are not included.
If you want an alpine 3.17 container image that includes the current LTS version of node, you can use node:lts-alpine3.17.

/lib64/ld-linux-x86-64.so.2: No such file or directory error

Background
I am using docker to do a school project. Specifically, I pulled an ubuntu image and here is the system config:
I then logged into the docker container (ubuntu) and set up elasticsearch. When I try to run
./bin/elasticsearch
I get the following error inside the docker container's terminal
/lib64/ld-linux-x86-64.so.2: No such file or directory
I have two main confusions:
what does that even mean?
How to solve it?
If you are running this on an M1 macbook, it's possible that you are running a native Arm image of ubuntu, instead of the emulated x86 image. If the elasticsearch distribution you are trying to install is for x86_64, then it attempts to link to the x86-64-native ld.so, which of course isn't present on different platforms.
Either install the package for the arm platform specifically if they provide one, or - more likely - run docker explicitly as the emulated x86_64 platform:
docker run --platform linux/x86_64 <image>
For docker-compose, add platform: linux/x86_64 according to the docs
services:
my-app:
platform: linux/x86_64
No idea what you are running in your container but for me, the reason was simply because a package (Prisma https://github.com/prisma/prisma/issues/8478#) did not find openssl packages and installing them on alpine image failed even with openssl manually installed.
It was fixed by switching to slim image and installing openssl with apt-get update && apt-get -y install openssl. I highly recommend not changing your platform since with my M1 the build time increased by 200s using linux/x86_64.
Completing #misnomer answer, I could not even build the image.
If that is the case just add FROM --platform=linux/x86_64 ..., from this source. Ex: FROM --platform=linux/x86_64 python:slim ...

Linux headers for ubuntu docker image 18.04

I am trying to install linux header for my ubuntu 18.04 docker image (ubuntu:18.04). Usually I will do sudo apt-get install linux-headers-$(uname -r) in my VM to get the current linux header packages.
But the docker image return the following when I run uname -r
root#0c4e24cca819:/# uname -r
4.19.76-linuxkit
Just wonder which linux header image I should use for ubuntu:18.04 docker image?
Docker by definition runs your current kernel. If you are on a machine whose kernel has not been packaged for Ubuntu then there is no package you can install to get its headers.
Looks like you're on a Mac, so definitely that is the case here. Perhaps you could ask the Docker for Mac maintainers to provide headers for some popular platforms for their kernel, but I suspect they don't want to take on that responsibility.
As a workaround, maybe run Docker inside Linux on e.g. Virtualbox.

Should I use Docker to create Linux OS within a Linux OS? [duplicate]

This question already has answers here:
How is Docker different from a virtual machine?
(23 answers)
Closed 5 years ago.
I recently started to learn Docker, and know it creates and runs Ubuntu within a container with just a simple command.
docker run -i -t ubuntu:14.04 /bin/bash
I also know that docker-machine uses VirtualBox to create Linux OS in a very handy way.
So what's the difference between them?
So docker run -i -t ubuntu:14.04 /bin/bash uses docker engine to create containers(ubuntu container in this case) and will use your Host OS to manage them. On the other hand docker machine will use virtualBox and create VMs(Linux) which will serve as docker hosts running docker engine on them. There are a few links you can refer to :
https://dougwells.gitbooks.io/docker-notes/content/what_is_docker/what_is_difference_between_docker-machine_and_dock.html
https://docs.docker.com/machine/overview/
https://docs.docker.com/engine/
The first command using docker run is to start a new container. Docker containers can be run anywhere - on your local machine, within a VM (Virtualbox, VMWare etc), in an instance in the cloud, on bare metal or even on your smartphone. All this requires is to have docker installed and running as a daemon / service
docker-machine is a tool used to mimic running docker containers locally using a VM. This is only because earlier versions of docker were not available on MacOS & Windows natively. As such a Linux OS is made available insider a virtual machine with docker installed. On this VM it was possible to run docker commands and docker containers as though it was running docker natively.
You should check out Docker for Mac and Docker for Windows if these are compatible with your setup.

Which linux official distribution are less than 100mb?

I need some Linux official distribution that are less than 100mb for pulling images from docker hub server.
so far I am familiar with debian and busybox. any more official suggestions?
Generally speaking a small linux image with docker, alpine linux is commonly used. The size of alpine linux is only 4MB. You can easily add packages as you need with apk command.
https://hub.docker.com/_/alpine/
$ docker pull alpine
$ docker images | grep alpine
alpine latest 4a415e366388 8 days ago 3.99 MB

Resources