- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道是否可以运行一个 rootless podman 容器在容器内启用 systemd(不要与控制容器本身的 systemd 服务混淆)在主机系统级别!)?如果是,我需要什么?
这是一个简单的 Dockerfile
我一直在尝试以非特权用户身份运行(以 root 用户身份运行良好!)
FROM ubuntu:focal
RUN apt-get -qqy update && apt-get -qqy --no-install-recommends install \
init
# Start the systemd Init service by default
CMD ["/sbin/init"]
我注意到在 $podman build -t foo:latest .
期间会发生以下情况。这也发生在 root 用户 btw 所以可能与问题无关:
...
Setting up systemd (245.4-4ubuntu3.13) ...
Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service → /lib/systemd/system/getty@.service.
Created symlink /etc/systemd/system/multi-user.target.wants/remote-fs.target → /lib/systemd/system/remote-fs.target.
Created symlink /etc/systemd/system/dbus-org.freedesktop.resolve1.service → /lib/systemd/system/systemd-resolved.service.
Created symlink /etc/systemd/system/multi-user.target.wants/systemd-resolved.service → /lib/systemd/system/systemd-resolved.service.
ln: failed to create symbolic link '/etc/resolv.conf': Device or resource busy
Created symlink /etc/systemd/system/multi-user.target.wants/ondemand.service → /lib/systemd/system/ondemand.service.
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-pstore.service → /lib/systemd/system/systemd-pstore.service.
Initializing machine ID from random generator.
Cannot set file attribute for '/var/log/journal', value=0x00800000, mask=0x00800000, ignoring: Input/output error
...
通过 $podman run -d foo:latest
使用该图像运行容器会导致 255 错误,我无法进一步调试。 podman ps
输出:
427b3ce050dc localhost/foo:latest /sbin/init 6 seconds ago Exited (255) 7 seconds ago quirky_poincare
我的 podman 版本是 3.3.1。有人知道这里发生了什么吗?如前所述,root 在同一 Dockerfile 下构建和运行同一容器会导致 systemd 在容器内完美运行!
我通过 loginctl enable-linger $user
为用户启用了 lingering
:
Enable/disable user lingering for one or more users. If enabled for a specific user, a user manager is spawned for the user at boot and kept around after logouts. This allows users who are not logged in to run long-running services. Takes one or more user names or numeric UIDs as argument. If no argument is specified, enables/disables lingering for the user of the session of the caller.
参见 manpage更多详情
最佳答案
是的,可以在无根 Podman 容器中运行 Systemd。
我在 Fedora 35 笔记本电脑上使用 Podman 3.4.1 试用了您的示例。它似乎工作。也许您遇到了一些错误,后来在较新的 Podman 版本中得到了修复?
[testuser@laptop ~]$ cat /etc/fedora-release
Fedora release 35 (Thirty Five)
[testuser@laptop ~]$ podman --version
podman version 3.4.1
[testuser@laptop ~]$ mkdir testdir
[testuser@laptop ~]$ cd testdir
[testuser@laptop testdir]$ emacs Dockerfile
[testuser@laptop testdir]$ cat Dockerfile
FROM ubuntu:focal
RUN apt-get -qqy update && apt-get -qqy --no-install-recommends install \
init
# Start the systemd Init service by default
CMD ["/sbin/init"]
[testuser@laptop e]$ podman build -t foo:latest .
STEP 1/3: FROM ubuntu:focal
Resolved "ubuntu" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/ubuntu:focal...
Getting image source signatures
Copying blob 7b1a6ab2e44d done
Copying config ba6acccedd done
Writing manifest to image destination
Storing signatures
STEP 2/3: RUN apt-get -qqy update && apt-get -qqy --no-install-recommends install init
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libapparmor1:amd64.
(Reading database ... 4127 files and directories currently installed.)
Preparing to unpack .../00-libapparmor1_2.13.3-7ubuntu5.1_amd64.deb ...
Unpacking libapparmor1:amd64 (2.13.3-7ubuntu5.1) ...
Selecting previously unselected package libcap2:amd64.
Preparing to unpack .../01-libcap2_1%3a2.32-1_amd64.deb ...
Unpacking libcap2:amd64 (1:2.32-1) ...
Selecting previously unselected package libargon2-1:amd64.
Preparing to unpack .../02-libargon2-1_0~20171227-0.2_amd64.deb ...
Unpacking libargon2-1:amd64 (0~20171227-0.2) ...
Selecting previously unselected package libdevmapper1.02.1:amd64.
Preparing to unpack .../03-libdevmapper1.02.1_2%3a1.02.167-1ubuntu1_amd64.deb ...
Unpacking libdevmapper1.02.1:amd64 (2:1.02.167-1ubuntu1) ...
Selecting previously unselected package libjson-c4:amd64.
Preparing to unpack .../04-libjson-c4_0.13.1+dfsg-7ubuntu0.3_amd64.deb ...
Unpacking libjson-c4:amd64 (0.13.1+dfsg-7ubuntu0.3) ...
Selecting previously unselected package libssl1.1:amd64.
Preparing to unpack .../05-libssl1.1_1.1.1f-1ubuntu2.9_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.1f-1ubuntu2.9) ...
Selecting previously unselected package libcryptsetup12:amd64.
Preparing to unpack .../06-libcryptsetup12_2%3a2.2.2-3ubuntu2.3_amd64.deb ...
Unpacking libcryptsetup12:amd64 (2:2.2.2-3ubuntu2.3) ...
Selecting previously unselected package libip4tc2:amd64.
Preparing to unpack .../07-libip4tc2_1.8.4-3ubuntu2_amd64.deb ...
Unpacking libip4tc2:amd64 (1.8.4-3ubuntu2) ...
Selecting previously unselected package libkmod2:amd64.
Preparing to unpack .../08-libkmod2_27-1ubuntu2_amd64.deb ...
Unpacking libkmod2:amd64 (27-1ubuntu2) ...
Selecting previously unselected package systemd-timesyncd.
Preparing to unpack .../09-systemd-timesyncd_245.4-4ubuntu3.13_amd64.deb ...
Unpacking systemd-timesyncd (245.4-4ubuntu3.13) ...
Selecting previously unselected package systemd.
Preparing to unpack .../10-systemd_245.4-4ubuntu3.13_amd64.deb ...
Unpacking systemd (245.4-4ubuntu3.13) ...
Setting up libapparmor1:amd64 (2.13.3-7ubuntu5.1) ...
Setting up libcap2:amd64 (1:2.32-1) ...
Setting up libargon2-1:amd64 (0~20171227-0.2) ...
Setting up libdevmapper1.02.1:amd64 (2:1.02.167-1ubuntu1) ...
Setting up libjson-c4:amd64 (0.13.1+dfsg-7ubuntu0.3) ...
Setting up libssl1.1:amd64 (1.1.1f-1ubuntu2.9) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up libcryptsetup12:amd64 (2:2.2.2-3ubuntu2.3) ...
Setting up libip4tc2:amd64 (1.8.4-3ubuntu2) ...
Setting up libkmod2:amd64 (27-1ubuntu2) ...
Setting up systemd-timesyncd (245.4-4ubuntu3.13) ...
Created symlink /etc/systemd/system/dbus-org.freedesktop.timesync1.service → /lib/systemd/system/systemd-timesyncd.service.
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service → /lib/systemd/system/systemd-timesyncd.service.
Setting up systemd (245.4-4ubuntu3.13) ...
Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service → /lib/systemd/system/getty@.service.
Created symlink /etc/systemd/system/multi-user.target.wants/remote-fs.target → /lib/systemd/system/remote-fs.target.
Created symlink /etc/systemd/system/dbus-org.freedesktop.resolve1.service → /lib/systemd/system/systemd-resolved.service.
Created symlink /etc/systemd/system/multi-user.target.wants/systemd-resolved.service → /lib/systemd/system/systemd-resolved.service.
ln: failed to create symbolic link '/etc/resolv.conf': Device or resource busy
Created symlink /etc/systemd/system/multi-user.target.wants/ondemand.service → /lib/systemd/system/ondemand.service.
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-pstore.service → /lib/systemd/system/systemd-pstore.service.
Initializing machine ID from random generator.
Selecting previously unselected package systemd-sysv.
(Reading database ... 4939 files and directories currently installed.)
Preparing to unpack .../systemd-sysv_245.4-4ubuntu3.13_amd64.deb ...
Unpacking systemd-sysv (245.4-4ubuntu3.13) ...
Setting up systemd-sysv (245.4-4ubuntu3.13) ...
Selecting previously unselected package init.
(Reading database ... 4956 files and directories currently installed.)
Preparing to unpack .../archives/init_1.57_amd64.deb ...
Unpacking init (1.57) ...
Setting up init (1.57) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
--> 8365295f680
STEP 3/3: CMD ["/sbin/init"]
COMMIT foo:latest
--> c5943cdefb8
Successfully tagged localhost/foo:latest
c5943cdefb8da63207de2195d08a00588ba1a725c9203f0642d2d070c505e717
[testuser@laptop testdir]$ podman run -d foo:latest
717f98bc12cd59297073985582f1c4cbc5718595da66ac8a1ee750b9e44bba10
[testuser@laptop testdir]$ podman logs 717f98bc12cd59297073985582f1c4cbc5718595da66ac8a1ee750b9e44bba10
[testuser@laptop testdir]$ podman container list
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
717f98bc12cd localhost/foo:latest /sbin/init 15 seconds ago Up 15 seconds ago laughing_nobel
[testuser@laptop testdir]$ podman container list
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
717f98bc12cd localhost/foo:latest /sbin/init 31 seconds ago Up 31 seconds ago laughing_nobel
[testuser@laptop testdir]$ podman container list
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
717f98bc12cd localhost/foo:latest /sbin/init 4 minutes ago Up 4 minutes ago laughing_nobel
[testuser@laptop testdir]$
关于Systemd 在无根的 podman 容器中可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69975828/
我需要将所有可用数据(包括记录的用户信息等)从 Android 中的应用程序迁移到不同的设备。基本上我需要的是将整个应用程序从一台设备导出到另一台设备(可能不止一台设备),包括所有应用程序的数据 最佳
我正在尝试查找可以让我以编程方式捕获来自 wifi 或移动网络的设备的所有网络数据包流量的资源或库。我相信不需要 root 就可以像 shark for root 这样混杂模式。会请求因为有 this
我尝试运行最新版本的 debian 和 alpine,但似乎以 root 用户身份运行。 我期待 echo $USER如果返回为空,则不应返回 root;然后我需要使用命令 whoami 进行验证如果
我已经在 ubuntu 主机上安装了 docker rootless。我有一个用于构建 timescaledb 的 Dockerfile,其中最重要的部分如下所示: # Install the too
我正在尝试在 Android 手机(无根)中运行一个脚本来完成以下任务。 进入camera 目录,将Camera 中的所有*.mp4 文件复制到backups,然后进入 backups 目录并将所有
在工作中,开发没有修订控制。我的意思是,只有当变更集准备好进行回归测试时,我们才被允许 checkin P4 仓库。我们无法检查校际变化!在开发过程中没有修订控制有很多问题,我不需要在这里讨论。相反,
我尝试在Linux系统上无根安装caffe。我发现了这个this指令。现在在编译caffe的某个时刻,我收到以下错误消息: $make all -j8 LD -o .build_release/lib
我有一个复杂的 Andriod 应用程序(Java 和 native 代码)最初是为 Android 2.x 系列设备构建的。我已经在 Android 4.3 版本的模拟器上工作了,但我不得不使用 a
我是一名优秀的程序员,十分优秀!