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

"Failed to get shell PTY: Protocol error" for an nspawn container with systemd inside

· 52CE 我爱测

I create containers with # debootstrap --variant=minbase --include=systemd,iproute2 buster "/var/lib/machines/test" And then I run it with: # systemd-nspawn --machine test Just for testing purposes. The container boot, when I try…

问题原文

原帖链接 · Antoine Catton · CC BY-SA 4.0

I create containers with

# debootstrap --variant=minbase --include=systemd,iproute2 buster "/var/lib/machines/test"

And then I run it with:

# systemd-nspawn --machine test

Just for testing purposes. The container boot, when I try to access it with machinectl I get the error:

# machinectl shell test
Failed to get shell PTY: Protocol error

After some googling, I realized that there was an old bug that generated this behavior, but this was fixed in systemd v226, and /usr/bin/systemd --version on my debian shows me the version 246.

I can get into the container using the "non systemd container" method, but my container runs systemd, I should be able to use machinectl.

已采纳解答

原帖链接 · Antoine Catton · CC BY-SA 4.0

It looks like I was missing dbus inside the container.

# chroot /var/lib/machines/test apt install dbus

Or using from the beginning:

# debootstrap --variant=minbase --include=systemd,dbus buster "/var/lib/machines/test"

both solves the problem.

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

资料来源与适用范围

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

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

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