0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ASP.NET Core + Docker環境をDocker CLI + Limaで動かす初期設定

Last updated at Posted at 2025-04-11

プライベートのmacにてDocker Desktopの利用をやめ,Docker CLI + Lima環境に移行しました.

その際にASP.NET Core + Dockerで構築したプロジェクトが動作するか試してみたのですが,デフォルトのLimaではASP.NET Coreコンテナのビルド時にエラーが起こってしまいました.

当記事では発生した問題と,その解決方法について簡単にまとめます.

環境

  • macOS Sequoia 15.4
  • Lima version 1.0.7

発生した問題

単にlimactl startコマンドで起動したデフォルト設定のLimaでdocker compose up -dを試みたところ,以下のようなエラーが発生しました.

/usr/share/dotnet/sdk/8.0.xxx/NuGet.targets(174,5): error : Read-only file system : '/app/src/obj/2134170y-3021-3548-8271-2e83u6e22s8ba.tmp'

ASP.NET Coreのビルドの際,objディレクトリにファイルを生成するようですが,Limaのインスタンスからではその書き込み権限がなく,エラーとなっている様子です.

解決方法(Limaの初期設定)

そこで以下の手順でLimaの環境を構築したところ,無事動作するようになりました.

1. Limaのインスタンス作成

以下のコマンドを実行して,インスタンスを作成します.

limactl create --name=[インスタンス名] template://docker

コマンド実行後にいくつか操作の選択肢を聞かれるので,Open an editor to review or modify the current configurationを選択します.

ローカルの~/.lima/[インスタンス名]/lima.yamlが開くので.mounts:の箇所にプロジェクトファイルのパスを記載します.

lima.yaml
mounts:
  - location: "~/your/project/path" # 追加
    writable: true

これによりLimaから指定パス以下のファイルへの書き込みが可能となります.

上記w追記後,以下のコマンドによりインスタンスを起動します.

limactl start [インスタンス名]

2. .NET SDKのインストール

.NET SDKをコンテナでも利用したい場合は,そのインストールが必要です.
lima shell [インスタンス名]コマンドでインスタンスのシェルを開き,以下のコマンドで.NET SDK(ここでは.NET 8系)をインストールします.

sudo apt update && sudo apt -y install dotnet-sdk-8.0

3. 設定完了

これにてLimaの初期設定は完了となります.

あとはlima docker compose up -dコマンドをローカルで実行,あるいはLimaのシェル内でdocker compose up -dする等でコンテナを立てれば,プロジェクトが動作するようになります!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?