Replies: 5 comments 16 replies
-
Nice initiative. Let's explore this :) There is a Hacker News comment from user Klasiaster about running Podman in Podman in Podman. Another thing: I wrote a Hacker News comment 26 April 2023 about The new systemd directive OpenFile= opens up the possibility to pass the file descriptor of a file from the host to a container running in a container.
|
Beta Was this translation helpful? Give feedback.
-
could it be that the storage volume is mounted with You'd probably need to pass the volume manually and make sure each sub-level gets a distinct directory |
Beta Was this translation helpful? Give feedback.
-
The following works till level 5 and more... The following: # Original image.
FROM quay.io/podman/stable as original
COPY ./Containerfile ./run.sh /home/podman/
RUN chmod +x /home/podman/*.sh
WORKDIR /home/podman podman build -f Containerfile -t "$name" --target original .
podman push "$name"
podman volume rm podman-root && podman volume create podman-root || true
podman run --privileged --device /dev/fuse -v "podman-root:/podman-root" -v "$HOME/.local/share/containers/storage:/var/lib/shared" --rm "$name" ./run.sh sr/bin/env bash
#
set -u
set -e
DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cd "$DIR" || exit 1
level="${1:-1}"
vol_name="podman-root-$level"
msg="-> $level. Container"
function indent() {
cat | sed "s@^@| @g"
}
function run_podman() {
# When you specify `--root` , than `storage-opts`
# in `/etc/containers/storage.conf` are ignored.
podman \
--root /podman-root/root \
--runroot /podman-root/runroot \
--storage-opt "additionalimagestore=/var/lib/shared" \
"$@"
}
function main() {
# Build the image.
echo "$msg: inside [version: $(cat /image.version)]"
# Run the image and build again.
if [ "$level" -lt 5 ]; then
echo "$msg: Launching a new container ..."
# We need to make a new volume for the next podman
# to have the stuff it needs stored.
echo "$msg: create volume:"
run_podman volume create "$vol_name" || {
echo "create failed: $vol_name"
exit 3
}
# We launch the new podman with root/runroot
# on the current mounted volume `data`.
# Then we mount the current data as
# [`additionalimages`](https://www.redhat.com/sysadmin/image-stores-podman)
# to next podman to have caching.
run_podman \
run \
-v "$vol_name:/podman-root:Z" \
-v "/var/lib/shared:/var/lib/shared" \
--privileged \
--rm ttl.sh/podman-test \
./run.sh "$((level + 1))" || true
echo
else
echo "$msg: Finally reached container level: $level"
fi
echo "$msg: leaving"
}
main 2>&1 | indent Questions:
|
Beta Was this translation helpful? Give feedback.
-
mount the current storage as an additional images store in the nested container |
Beta Was this translation helpful? Give feedback.
-
From issue: #22088: To continue the discussion here: Discovering the possibility to nest containers in https://github.com/gabyx/container-nesting (which was specifically made for this bug report to properly test this). Note: This container nesting is not some academic example (although for nesting levels >2 it migth be), this usecase appears in CI when we want the ability to not have everything in one top-level image only but leave room to run other containers inside the top-level one. Container nesting works with user It seems that when running the container nesting recursion as user I dont think its a podman issue (hopefully) but maybe a image issue or a configuration issue. It would however be nice if the podman image would support such kind of nesting (1-2 levels). Steps to reproduce the issueSteps to reproduce the issue
Note: The image which is used is an Describe the results you receivedThe permissions on Describe the results you expectedThe Note: I am using podman info outputhost: arch: amd64 buildahVersion: 1.33.5 cgroupControllers: - cpu - io - memory - pids cgroupManager: systemd cgroupVersion: v2 conmon: package: Unknown path: /nix/store/wp1wic4bsd28qb7hs04dr7dsgls5j8pf-conmon-2.1.10/bin/conmon version: 'conmon version 2.1.10, commit: ' cpuUtilization: idlePercent: 98.82 systemPercent: 0.58 userPercent: 0.6 cpus: 32 databaseBackend: sqlite distribution: codename: uakari distribution: nixos version: "24.05" eventLogger: journald freeLocks: 2019 hostname: linux-nixos idMappings: gidmap: - container_id: 0 host_id: 100 size: 1 - container_id: 1 host_id: 100000 size: 10000000 uidmap: - container_id: 0 host_id: 1000 size: 1 - container_id: 1 host_id: 100000 size: 10000000 kernel: 6.6.19 linkmode: dynamic logDriver: journald memFree: 39401140224 memTotal: 67342225408 networkBackend: netavark networkBackendInfo: backend: netavark dns: package: Unknown path: /nix/store/vwrqp3pfj17p0zd5gdnrkrvr702z838r-podman-4.9.3/libexec/podman/aardvark-dns version: aardvark-dns 1.10.0 package: Unknown path: /nix/store/vwrqp3pfj17p0zd5gdnrkrvr702z838r-podman-4.9.3/libexec/podman/netavark version: netavark 1.7.0 ociRuntime: name: crun package: Unknown path: /nix/store/h9wpwj1zjz6qjw3q331k757cq27kmj9k-crun-1.14.4/bin/crun version: |- crun version 1.14.4 commit: 1.14.4 rundir: /run/user/1000/crun spec: 1.0.0 +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL os: linux pasta: executable: "" package: "" version: "" remoteSocket: exists: true path: /run/user/1000/podman/podman.sock security: apparmorEnabled: false capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT rootless: true seccompEnabled: true seccompProfilePath: "" selinuxEnabled: false serviceIsRemote: false slirp4netns: executable: /nix/store/vwrqp3pfj17p0zd5gdnrkrvr702z838r-podman-4.9.3/libexec/podman/slirp4netns package: Unknown version: |- slirp4netns version 1.2.3 commit: c22fde291bb35b354e6ca44d13be181c76a0a432 libslirp: 4.7.0 SLIRP_CONFIG_VERSION_MAX: 4 libseccomp: 2.5.5 swapFree: 77309407232 swapTotal: 77309407232 uptime: 5h 53m 35.00s (Approximately 0.21 days) variant: "" plugins: authorization: null log: - k8s-file - none - passthrough - journald network: - bridge - macvlan - ipvlan volume: - local registries: search: - docker.io - quay.io store: configFile: /home/nixos/.config/containers/storage.conf containerStore: number: 25 paused: 0 running: 0 stopped: 25 graphDriverName: overlay graphOptions: {} graphRoot: /home/nixos/.local/share/containers/storage graphRootAllocated: 1049659179008 graphRootUsed: 181234888704 graphStatus: Backing Filesystem: btrfs Native Overlay Diff: "true" Supports d_type: "true" Supports shifting: "false" Supports volatile: "true" Using metacopy: "false" imageCopyTmpDir: /var/tmp imageStore: number: 622 runRoot: /run/user/1000/containers transientStore: false volumePath: /home/nixos/.local/share/containers/storage/volumes version: APIVersion: 4.9.3 Built: 315532800 BuiltTime: Tue Jan 1 01:00:00 1980 GitCommit: "" GoVersion: go1.21.7 Os: linux OsArch: linux/amd64 Version: 4.9.3 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to test how many times we can nest containers (podman images)
I use the following
Containerfile
:and the
run.sh
:and the I run the recursion with:
I have the followin in
/etc/subuids
and/etc/subgids
:which means I can allocate 1000000 subuid's etc. which should be enough to run the container nest recursion to level above 3:
the output however crashes with:
Anybody has an idea what the problem is, that after nesting level 2, the recursion gives up??
Its an intersting thing to nest containers, better know as "podman in podman" etc frequently arising in CI etc.
Thanks for any insight.
Beta Was this translation helpful? Give feedback.
All reactions