Tweet
Logo
    GitHub Codespaces の features を使う
    GitHub Codespaces の features を使う

    GitHub Codespaces の features を使う

    • はじめに
    • 設定
    • 利用できる features
    • おわりに

    はじめに

    この記事では GitHub Codespacese の devcontainer に Dockerfile を修正せずに機能追加を行う方法を記載します

    設定

    設定は非常に簡単です

    .devcontainer/devcontainer.json の features に設定を記載してください

    {
    	"image": "mcr.microsoft.com/devcontainers/universal:2",
    	"features": {
    		"git": "latest"
    	}
    }
    devcontainer.json によって devcontainer で最新版の git を使えるようにする

    features には devcontainer で使いたい機能を指定することが出来ます

    Dev Container Features reference

    Development container “Features” are self-contained, shareable units of installation code and development container configuration. The name comes from the id...

    containers.dev

    features を使うことで、 Dockerfile を修正せずに機能を追加する事が出来ます

    例えば devcontainer に本番のコンテナと同じものを利用したいというようなケースでも、 features を使えば本番のコンテナに余計なツールなどをインストールせずに開発環境でのみ追加の設定を入れる事が出来ます。

    利用できる features

    利用できる feature はここから確認可能です。

    features/src at main · devcontainers/features

    A collection of Dev Container Features managed by Dev Container spec maintainers. See https://github.com/devcontainers/feature-starter to publish your own - features/src at main · devcontainers/fea...

    github.com

    features/src at main · devcontainers/features

    おわりに

    GitHub Codespaces の features の設定方法を記載しました。

    とても便利な機能なので積極的に使っていくと devcontainer のセットアップが楽になると思います。

    © 2025 DROBE All rights reserved.