LoginSignup
3
2

More than 1 year has passed since last update.

WSL2 Docker 環境構築

Posted at

WSL2 インストール手順

管理者権限で Powershell を起動する。

start -verb runas powershell

WSL インストールコマンドを実行する。

wsl --install

バックアップを残しておきたい場合は export オプションを使用する。

wsl --export Ubuntu ubuntu_backup.tar

リストアしたい場合は import オプションを使用する。

# 現在登録されている仮想マシンを削除する。
wsl --unregister Ubuntu
# 仮想マシンの VHD が置かれているデフォルトパス
$ubuntu_vhd_path="${env:LOCALAPPDATA}\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState";
# 仮想マシンを復元する。
wsl --import Ubuntu $ubuntu_vhd_path ubuntu_backup.tar

復元後、仮想マシンのデフォルトユーザが root になっている為、 /etc/wsl.conf を作成する。

/etc/wsl.conf
[user]
default=user_name

仮想マシンを再起動して wsl.conf を適用する。

wsl -t Ubuntu

参考資料

WSL 仮想マシンへの Docker インストール手順

公式に配布されているインストールスクリプトを取得し、実行する。

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

dockerd , docker , docker compose がインストールされる。

参考資料

WSL ホストマシンへの Docker インストール手順

Rancher Desktop のインストーラを取得し、実行する。

参考資料

3
2
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
3
2