Images with 60 or more layers fail to start: "mount …/rootfs: No such file or directory"

オープン
#253 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
docker, linux, rust

調査の方向性

Start with mount_rootfs in crates/kiri-init/src/linux/container.rs and inspect how it builds overlayfs mount options. The report identifies the 4 KiB mount option limit and says the Linux engine needs a fallback for older kernels; it also describes a branch that uses the newer mount API and a test mounting 120 layers. Done means the 60 layer repro starts, the 120 layer test passes, and older Linux kernels retain the fallback.

索引モデルが issue の本文から書いたものです。

説明

Kiri version and system

0.2.1 built from the v0.2.1 tag (0.2.0 release does the same) on macOS 27.2 (Apple silicon)

What you did

I hit this with nixos/nix, which has 69 layers. Here's a smaller repro:

mkdir layers65 && cd layers65
{ echo "FROM alpine:3.22"; for i in $(seq 1 64); do echo "RUN echo $i > /layer-$i"; done; } > Dockerfile
docker build -t layers65 .
docker run --rm layers65 cat /layer-64

and

docker run --rm nixos/nix:2.34.9 nix --version
What happened
docker: Error response from daemon: run <id>: mount /var/lib/kiri/containers/<id>/rootfs: No such file or directory (os error 2)
What you expected instead

The container starts. Both work on Docker and OrbStack.

Anything else

It's exactly at 60: with 59 layers (alpine plus 58 RUN lines) the image
starts, with 60 it doesn't.

I think it's the mount options getting too long. mount_rootfs
(crates/kiri-init/src/linux/container.rs:406) puts every layer in one
lowerdir= string, and each layer is a 64-character hash, so about 65
bytes per layer. mount(2) only copies one page (4 KiB) of options, so
around 60 layers the string gets cut off in the middle of a name and
overlayfs can't find that directory.

The guest kernel is 6.18, so the newer mount API can take each layer
separately with lowerdir+ (6.8 and later), which goes up to overlayfs's
own limit of 500. I've got that working on a branch, with a fallback to
the current mount(2) call for older kernels on the Linux engine and a
test that mounts 120 layers. nixos/nix runs with it. Happy to open a PR
if you'd like it done that way.

主要言語
Rust
スター
7.5k
フォーク
329
平均マージ
7時間 48分
マージ済み PR(30日)
105

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

libracoder/kiri のほかの issue

libracoder/kiri の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。