0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows(WSL2)でDocker開発環境を構築する

0
Posted at

WindowsでDockerを動かすときに少し手間取ったので、記録に残していきます。

環境構築の3ステップ

① WSL2の有効化とUbuntuのインストール

PowerShellを管理者権限で開き、以下のコマンドを叩くだけで準備は整います。

wsl --install

インストール後、Microsoft Storeから「Ubuntu」を入手し、初期設定(ユーザー名とパスワード)を済ませます。

② Docker Desktopのインストールと設定

公式サイトからDocker Desktopをインストールします。インストール時の設定で 「Use the WSL 2 based engine」 に必ずチェックを入れてください。

設定の確認: Dockerの Settings > Resources > WSL Integration で、インストールしたUbuntuのスイッチが「ON」になっていることを確認します。

③ Ubuntu側での動作確認

Ubuntuのターミナルを開き、以下のコマンドでクジラのマーク(Dockerのバージョン)が出れば成功です。

docker --version

ハマりどころと対策

メモリ不足: Docker Desktopはメモリを多く消費します。%USERPROFILE%.wslconfig ファイルを作成し、メモリ制限(例: memory=4GB)をかけると、Windows側の動作が重くなるのを防げます。

追記

一番やりがちなのが、Windows側のフォルダ(/mnt/c/...)でプロジェクトを作ってしまうことです。
Windows側で作ってしまうとDockerの起動が異常に遅い、または権限エラーが出ることがあります。
必ずUbuntuのホームディレクトリ(~/)配下で作業しましょう。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?