blog.bouzuya.net

2025-12-15 Dev Container の Rust の pre-built image をすこし調べてみた

今日は bouzuya/fubako の Dev Container の設定を見直した。その流れで Dev Container の Rust の pre-built image についてすこし追いかけてみた。

mcr.microsoft.com/devcontainers/rust:1-1-bullseye という Docker image が指定されているのだけど、 bullseye (debian 11) はおそらく bookworm (debian 12) や trixie (debian 13) があるはずで最新ではなさそうだし、 1-1- の意味は分からないけどこちらも最新ではなさそうに見えた。

これらは VS Code の Dev Containers: Add Dev Container Configuration Files... コマンドで追加されたものなので、そこからたどる。

VS Code の Dev Containers: Add Dev Container Configuration Files... コマンドから Add configuration to workspace を選び、 Learn More を選ぶと https://containers.dev/templates が表示される。

このページから Rust のテンプレートを検索して、リンクをたどると devcontainers/templates がソースのようだ。

https://github.com/devcontainers/templates/tree/main/src/rust

リポジトリの構造・挙動はよくわからないが、ファイルを眺めるとテンプレートが置いてある。

https://github.com/devcontainers/templates/blob/00794d01c59f7c7278e7680ffeadf9ed2cf23c51/src/rust/.devcontainer/devcontainer.json#L6

    "image": "mcr.microsoft.com/devcontainers/rust:2-1-${templateOption:imageVariant}"

templateOption:imageVariant のいまの既定値は↓のとおり trixie

https://github.com/devcontainers/templates/blob/00794d01c59f7c7278e7680ffeadf9ed2cf23c51/src/rust/devcontainer-template.json#L18

つまり、最新のテンプレートでの Docker image は次のようになる。

mcr.microsoft.com/devcontainers/rust:2-1-trixie

これで一区切り。

だが、そも、この Docker image は大丈夫なのか、気になった。

前述の devcontainers/templates の README からリンクが貼られているのが devcontainers/images リポジトリ。

https://github.com/devcontainers/images/tree/main/src/rust

このリポジトリも構造・挙動は分からないが、 Docker image のタグの説明などが書かれている。

Dockerfile を見ると FROM rust:1-${VARIANT} で debian OS version が指定されている。ほかは subversion のインストールがされているくらい。

https://github.com/devcontainers/images/blob/5498638fb74891e8ef07826d0efaa6adef8a1fcb/src/rust/.devcontainer/Dockerfile#L3

実際にいろいろ入れているのは devcontainer.json で Dev Container の features を使ったものになっていそうだ。

https://github.com/devcontainers/images/blob/5498638fb74891e8ef07826d0efaa6adef8a1fcb/src/rust/.devcontainer/devcontainer.json

最新のバージョンは 2.0.3 のようで、その history を見る。

https://github.com/devcontainers/images/blob/main/src/rust/history/2.0.3.md

rustup component のテーブルが怪しい。

rust-analysis って何だ……? 1.90.0 ってバージョン間違っているのでは……とか。

調べてみると rust-analysis 自体は rls (rust-analyzer 以前の Language Server 実装) から使われていたものらしい。

https://rust-lang.github.io/rustup/concepts/components.html#previous-components

rust-analysis というものが存在すること自体は間違いじゃないみたいだ。ただ、おそらく features の rust でインストールされるのはおそらく rust-analyzer ではないだろうか。

devcontainers/features リポジトリで Default Value として指定されているコンポーネントも rust-analyzer だ。

https://github.com/devcontainers/features/tree/b0188f0a5ef98f1c3217b6c0fe14c3ee472fad68/src/rust

あとで Pull Request をつくるかもしれない。


今日のコミット。