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?

WSL Containerを触ってみる

0
Last updated at Posted at 2026-07-01

1. こちらの記事について

こちらではWSL Containerの構築説明をいたします。
なにかの参考にしていただけると。。。

2. WSL Containerを構築する

2-1. WSLをアップデートする

# windows/cmd

wsl --update --pre-release
コンソール結果
# windows/cmd

更新プログラムを確認しています。
Linux  Windows サブシステムをバージョン 2.7.10 に更新しています。

2-2. シャットダウンして、CMDを閉じる

# windows/cmd

# シャットダウン
wsl --shutdown

# CMDを閉じる
exit

2-3. wslcのバージョン確認

# windows/cmd

wslc version
コンソール結果
# windows/cmd

wslc 2.9.3.0

3. wslcを簡易で動かす

3-1. Alpine環境を取得し、コンテナの中に入る

# windows/cmd

wslc run --rm -it alpine
コンソール結果
# windows/cmd

イメージ 'alpine' が見つかりません。プルしています
latest: Pulling from library/alpine
55afa1ecc21d: Pull complete
Digest: sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b
Status: Downloaded newer image for alpine:latest

3-2. OSのバージョンを確認

# Alpine/sh

# Alpineのバージョン確認
cat /etc/os-release

# Alpineから抜ける
exit
コンソール結果
# Alpine/sh

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.24.1
PRETTY_NAME="Alpine Linux v3.24"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

4. よく使いそうなコマンド

# windows/cmd

# イメージを取得
wslc pull alpine

# イメージを取得し、コンテナの中に入る
wslc run --rm -it alpine

# コンテナがバックグラウンドで立ち上がっているものを確認
wslc pull nginx
wslc run --name nginx-test -d -p 8080:80 nginx
wslc ps -a
# 「http://localhost:8080/」にアクセスで画面確認

# コンテナ停止
wslc stop nginx-test
wslc list     # 「wslc ps」と同じ
wslc ps -a    # まだ表示される

# 停止後に削除
wslc remove nginx-test
wslc ps -a    # 表示されなくなった

# すべて停止
for /f %i in ('wslc ps -q') do wslc stop %i

# すべて削除
for /f %i in ('wslc ps -q') do wslc remove %i

# エイリアス作成
doskey wslcstop=for /f %i in ('wslc ps -q') do wslc remove %i
wslcstop
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?