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?

最もシンプルかつ確実にWindowsでDocker DesktopなしでDockerを動かす

Last updated at Posted at 2025-10-30

はじめに

Windows で Docker を動かす際は Docker Desktop を利用する方法もありますが大きな企業では商用利用が有料となっています。

今回は Docker Desktop を利用しないやり方で、なおかつシンプルで確実に Docker を動作させるところを目指します。
また、なるべく公式の手法に則ることを意識しています。

Step 1 - 仮想化の有効化

Windows で Docker を動かす際は WSL を媒介する必要があります。(Docker Desktop でも同様)

まずは Powershell を管理者として実行。

管理者として Powershell を開く

以下のようにメニューから開くことができます。
image.png

次に Powershell で以下のコマンドを実行。

Powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

これらの設定は GUI からでも設定できますが Windows の機能を管理する場合は dism.exe を利用するのがシンプルです。

終了後、再起動 してください。

Step 2 - Ubuntu を動作させる

再起動後、もう一度管理者として Powershell を開いて以下を実行します。

Powershell
wsl --install

うまくいけばユーザー作成のプロンプトが表示されるのでユーザー名とパスワードを入力してください。
その後 Ubuntu のプロンプト(黄緑と青のプロンプト)が表示されれば成功です。

Case 1: 「 'wsl --install -d <Distro>' を使用してインストールします。」

このメッセージが表示される場合、組み込み版の wsl が呼び出されています。
ストア版(公式推奨)を使用したいので以下のコマンドで wsl を更新してください。

Powershell
wsl --update --web-download
Case 2: 「サーバー名またはアドレスは解決されませんでした」

ネットワークに問題がある可能性があります。
単純にネットワークにつながっていないか、アクセスが制限されている可能性があるので確認してください。

Step 3 - Docker を動作させる

Step 2 で Ubuntu が立ち上がったので次は Ubuntu に Docker を入れます。
Ubuntu のプロンプトであることを確認して以下を順に実行してください。
(Powershell に戻ってしまった場合、 wsl -d Ubuntu で立ち上げることが可能です)

Ubuntu
sudo apt update && sudo apt upgrade -y
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

なお、sudo コマンド実行時にはユーザー作成時のパスワードを求められることがあります。
入力した際にパスワードが入力されていないように見えることがありますが、通常の仕様なので気にせず入力を続けてください。

以上のコマンドを実行し終わった時点で Docker が動作する環境になっているはずです。
以下のコマンドで Hello from Docker! からはじまるメッセージが表示されたら成功です。

Ubuntu
sudo docker run hello-world

補足事項

1. systemctl で Docker を動作させる

環境によっては最初から動作していることもあります。
sudo systemctl status dockeractive (running) と表示されていれば動作しています。

動作していない場合、/etc/wsl.conf に以下の内容を追加・編集してください。

/etc/wsl.conf
[boot]
systemd=true

その後、ファイルを保存して閉じた後、Powershell 側で wsl --shutdown を実行します。
次に、再度 WSL を立ち上げて以下のコマンドを実行します。

Ubuntu
sudo systemctl enable docker
sudo systemctl start docker

その後、sudo systemctl status dockeractive (running) が表示されていることが確認できれば成功です。

2. sudo なしで Docker を動作させる

通常 Docker コマンドを実行するには sudo (管理者権限で実行)をつける必要がありますが、面倒な場合はユーザーを docker グループに追加することができます。

Ubuntu
sudo usermod -aG docker $USER

この後、Powershell 側で wsl --shutdown を実行した後に再度 WSL を開くと有効になります。

参考

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?