大网数据广告活动
服务器运维问答

What linux name and version will I see in a container?

· 52CE 我爱测

I execute cat /etc/os-release in a container. I have an Ubuntu 22.04 docker host. When I run a container, and see the linux os-release file inside the container, I see my Ubuntu name, regardless in which container I execute it...…

问题原文

原帖链接 · g.pickardou · CC BY-SA 4.0

I execute cat /etc/os-release in a container.

I have an Ubuntu 22.04 docker host. When I run a container, and see the linux os-release file inside the container, I see my Ubuntu name, regardless in which container I execute it...

However I also have an other Kubernetes cluster also on Ubuntu 22.04 (no docker, the cluster configured to use containerd directly). If I create a deployment based on any image, when I see the os-release file, I see an image specific linux name, which clearly comes from the image itself, sometime alpine, sometime bookworm, etc.

Why is this different behavior?

社区高分解答

原帖链接 · Quantim · CC BY-SA 4.0

The /etc/os-release file is based on the container base image, if you get same version as your host, it only means you run images based on Ubuntu 22.04 You can test it with the container based on different system

Example from my machine running on Ubuntu, first command from host, second from container

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
...
$ docker run --rm -ti node:16 bash
root@3d48cdfe1d97:/# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
..

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-06-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。