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

Running dmesg on Docker results in "dmesg: read kernel buffer failed: Permission denied"

· 52CE 我爱测

In order to debug why this issue occurs the following command is run on a container: docker run -it <dockerImageName> dmesg results in: dmesg: read kernel buffer failed: Permission denied Attempts Running docker run -it <dockerIm…

问题原文

原帖链接 · 030 · CC BY-SA 3.0

In order to debug why this issue occurs the following command is run on a container:

docker run -it <dockerImageName> dmesg

results in:

dmesg: read kernel buffer failed: Permission denied

Attempts

  1. Running docker run -it <dockerImageName> sudo dmesg returns the same issue

已采纳解答

原帖链接 · Maniankara · CC BY-SA 3.0

as Michael Hampton mentioned, containers are meant to run only single atomic service. As a matter of fact, one should understand that containers are not virtual machines but a single process by itself on your localhost.

Nevertheless, I got to know that, its a bit more harder to get SystemD working inside a container from here

I was able to get SystemD working inside an image built FROM centos:centos7 with:

docker run --privileged -ti -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup trinitronx/ansible-base:stable-centos7 /usr/sbin/init

For some undocumented reason the variable container=docker is apparently required. /sys/fs/cgroup is also required, as SystemD needs cgroups to work properly according to RedHat Bug 1033604.

After doing this, try to login to the container using docker exec -it <container> /bin/bash and then you could execute your systemctl commands.

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

资料来源与适用范围

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

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

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