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?

WSL2(Ubuntu)にDocker Engineをインストール(Docker Desktop不要)

Posted at

Windows環境でWSL2(Ubuntu)を使って開発している方向けに、Docker Desktopを使わずにDocker Engineを直接インストールする手順をまとめました。
Docker Desktopは便利ですが、ライセンスやリソース消費の面で気になる方も多いと思います。そこで今回は、WSL2上のUbuntuにDocker Engineを直接導入する方法を記録します。
また、Docker EngineをWSL2内に直接インストールすることで、Windows ↔ Linux間のオーバーヘッドを減らし、より高速かつ軽量な動作が期待できます。特に、ビルドやコンテナ起動のレスポンスが向上します。
なお、WSL2とUbuntuの導入が完了している前提で進めます。

前提条件

  • WSL2が有効かされている
  • Ubuntuがインストール済み
  • sudo 権限がある

構築手順

パッケージ更新と依存関係のインストール

sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release

Docker公式GPGキーの追加

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

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/null

Docker Engineのインストール

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

ユーザーを docker グループに追加(再ログインが必要)

sudo usermod -aG docker $USER
  • WSL2を再起動する
wsl --shutdown

動作確認(再ログイン後)

docker コマンドが使えるか確認

docker version
docker run hello-world

Dockerサービスが起動しているか確認

docker info

Dockerデーモンの状態を確認

ps aux | grep dockerd
  • dockerd が表示されていれば、デーモンが起動中

以上、WSL2上のUbuntuにDocker Engineを直接インストールする手順を記録しました。
Docker Desktopを使わずに構築することで、ライセンスの制約やリソース消費を回避しつつ、より軽量で高速な開発環境が実現できます。
今後はこの環境をベースに、DifyなどのAIエージェントやセルフホスト型アプリケーションの構築にも活用していく予定です。
技術者視点での納得感ある環境構築を目指す方の参考になれば幸いです。

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?