skip to Main Content

I am running docker

$ docker --version
Docker version 23.0.1, build a5ee5b1

on Ubuntu 22.04

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:   jammy

and kernel

$ uname -r 
5.19.0-35-generic

From what I understand, Docker containers use their host kernel. But, according to this, that with running in Windows or Mac, the linux kernel in the docker container will use linuxkit.

However, on my Ubuntu 22.04 host machine, I pulled the ubuntu:18.04 and found that its kernel was

root:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:    18.04
Codename:   bionic
root/# uname -r
5.15.49-linuxkit

Why is this the case? How can I run the docker container with the same linux kernel as it apparently should? As it also states in this post?

2

Answers


  1. Check whether you’re connecting to remote machine as docker host.

    env | grep DOCKER

    See if you find DOCKER_HOST or similar entries that point to a remote host.

    Login or Signup to reply.
  2. If you’re using Docker Desktop, this always runs an embedded Linux virtual machine, even if you’re using it on native Linux. This has some minor advantages like it being very easy to completely reset the environment, but it’s not actually necessary.

    You clarify in a comment that you are in fact using Docker Desktop on Linux. In a container you’re seeing the VM’s kernel version, but since a VM is in fact involved, it’s a separate kernel from the host kernel. (You are in the same "Windows or Mac" state you suggest in the question, even though you’re actually on a Linux host.)

    If you don’t mind losing access to the Docker Desktop GUI tool, you can gain some efficiency and flexibility by uninstalling Docker Desktop and installing the Docker Engine directly on the host. This will behave the way you expect, and containers will share the host’s kernel.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search