Which linux official distribution are less than 100mb? - linux

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

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 ...

Which Operating System is Docker virtualizing when it runs the Node image?

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

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.

docker linux container doesn't support driver development?

To develop driver program, we need /lib/modules//build directory. But I found under docker image of centos, even after I
yum install kernel-devel
There's still no such a directory with all its contents. Question:
(1) how to make it possible to develop driver in a docker linux environment?
(2) is it possible to load this developed module?
Docker is not virtual machine.
Ubuntu with docker is not real ubuntu.
If you want to develop with ubuntu, you should use virtualbox or vmware.
Check this link for more information
Docker uses the kernel of the host machine.
After reading this page, I almost gave up building a kernel module in Docker so I'm adding this answer hoping it helps somebody. See also what-is-the-difference-between-kernel-drivers-and-kernel-modules
You can build Kernel modules in Docker as long as the Kernel source required for the build is available inside Docker. Lets say you want to build against the latest kernel source available in your yum repos, you could install the kernel source using yum install kernel-devel. The source will be in /usr/src/kernels/<version> directory. You could install specific version of kernel-devel from your repo if that is what you want.
Then build the module using $ make -C <path_to_kernel_src> M=$PWD where the path to the kernel source would be /usr/src/kernels/<version>.
Read - Kernel Build System ยป Building External Modules
Docker container uses the kernel of the host machine so if you want to build against the running kernel, i.e., the kernel of the Docker host machine, you could try running the container in privileged mode and mounting the modules directory. docker run --name container_name --privileged --cap-add=ALL -v /dev:/dev -v /lib/modules:/lib/modules image_id See this
You should not load the modules on a kernel that is not the same as the one the module was built for. You could force install it but that is highly discouraged. Remember your running kernel, i.e., the Docker host kernel, is the kernel of the Docker container irrespective of what kernel-devel version you installed.
To see the kernel the module was built for (or built using), run modinfo <module> and look for vermagic value.
Dynamic Kernel Module Support is also worth a read.

Resources