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.
Related
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 ...
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
I release ARM binaries of my software, by running the compiler toolchain on an emulated ARM machine.
Linux can run foreign binaries by registering qemu-user-static in /proc/sys/fs/binfmt_misc/. This allows you to run an ARM32 or ARM64 Docker image on an x86_64 Docker host, as follows:
Preparation:
# Apply `binfmt_misc` changes on host OS
docker run --rm --privileged multiarch/qemu-user-static:register --reset
Dockerfile:
# Get x86_64 qemu-user-static binaries
FROM debian:buster
RUN apt-get update && apt-get install -qqy qemu-user-static
# Get cross-arch rootfs
FROM arm64v8/golang:latest
COPY --from=0 /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static
This works great on Docker for Linux.
It also works great on Docker for Windows when using Linux Containers (MobyLinuxVM)
It doesn't work when using Docker for Windows when using Windows Containers (LCOW / hcsdiag mode). I want to use this mode because it can run both Linux and Windows containers. But it's not possible to modify the binfmt_misc file via the --privileged flag:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Windows does not support privileged mode.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
Current (1803-era) versions of Hyper-V HCS run a real Linux kernel, not a WSL one. I guess it should be possible to modify the host's binfmt_misc directory.
How is it possible to run a Linux/ARM container image on a Windows/x86_64 Docker host running LCOW?
Is it possible to modify the Linux host image used by LCOW?
Is there any other way to get a unified docker daemon that is capable of running Windows/x86_64, Linux/x86_64 and Linux/ARM Docker images?
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.
I'm developing on OSX using Docker Machine. I used the quickstart terminal to let it create the default VM which is extremely minimal:
In an OS X installation, the docker daemon is running inside a Linux VM called default. The default is a lightweight Linux VM made specifically to run the Docker daemon on Mac OS X. The VM runs completely from RAM, is a small ~24MB download, and boots in approximately 5s.
I want to install dnsmasq, but none of these instructions could work. I expect to come across this kind of problem again, so beyond installing dnsmasq I want to have some tool such as apt-get to be able to easily install things. With so few commands available I don't know how to get started. I have curl, wget, sh, git, and other very basic commands. I don't have any of the following:
apt
apt-get
deb
pkg
pkg_add
yum
make
gcc
g++
python
bash
What can I do? Should I just download a more complete VM such as Ubuntu? My laptop is not very fast so a very lightweight VM was very appealing to me, but this is starting to seem like a bit much.
The docker-machine VM is based on TinyCore. To install extra packages use tce or tce-load, the apt-get counterpart of TinyCore.
A word of warning, you shouldn't treat the docker-machine VM as a regular VM where you install tons of packages and customize. It's only meant to run containers. It's best to keep it that way.