Docker on WSL2 セットアップガイド
突合用のスタンドアロン端末にDocker Desktopを入れていましたが、商用利用では有料なことを失念していた。
そのため、WSL2にdocker-cliを入れる構成に変更。
セットアップ手順
Section titled “セットアップ手順”1. Docker Desktopのアンインストール
Section titled “1. Docker Desktopのアンインストール”まずは既に動いているDocker Desktopを停止してアンインストール。
# Chocolateyでアンインストールchoco uninstall docker-desktop2. WSLのインストール
Section titled “2. WSLのインストール”wsl --installインストール時の設定:
- 「Enter new UNIX username:」: 任意のユーザー名を入力
- 「Enter new UNIX password:」: パスワードを入力
デフォルトでUbuntuがインストールされ、Windowsのスタートメニューから起動できる
3. Docker Engineのインストール
Section titled “3. Docker Engineのインストール”参考: Docker Engine を Ubuntu にインストールする
必要なパッケージをインストール
Section titled “必要なパッケージをインストール”sudo apt updatesudo apt install ca-certificates curl gnupg lsb-releaseDockerの公式GPGキーを追加
Section titled “Dockerの公式GPGキーを追加”sudo mkdir -m 0755 -p /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgDockerリポジトリを追加
Section titled “Dockerリポジトリを追加”echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullDockerをインストール
Section titled “Dockerをインストール”sudo apt updatesudo apt install -y docker-ce docker-ce-cli containerd.io4. 非rootユーザーでDockerを使用する設定
Section titled “4. 非rootユーザーでDockerを使用する設定”現在のユーザーをdockerグループに追加:
sudo usermod -aG docker $USER設定を反映させるには、一度ログアウトして再度ログインする必要があります
WSL(Windows Subsystem for Linux)
Section titled “WSL(Windows Subsystem for Linux)”Windows上でLinuxのコマンドラインやツールを実行できる環境。
WSLの第2世代。以下の特徴があります:
- より高速で正確にLinuxを再現
- 起動が高速
- WindowsとLinux間のファイル共有が簡単
- Dockerコンテナを効率的に実行可能
その他のメモ
Section titled “その他のメモ”winget: http://nichicom-system/nichicomsys/nichicomsns/entry.aspx?entry=1143890