Introduction

備忘録。
Docker Desktop は商用利用不可 (一定以上の規模の企業) とか Docker のためだけに WSL (Windows Subsystem for Linux) はちょっと…みたいな感じで調べたら Microsoft 公式からちゃんと Docker を使える手順が提供されていました、というお話。

How to do?

作業の開始: コンテナー用の Windows の準備#Windows Server を参考にすると簡単に使えます。

インストールされるのは Docker Community Edition (Docker CE) ですがこれで十分。
商用利用できますし。
…Windows コンテナですけど。

1
2
$ Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1
$ .\install-docker-ce.ps1

このスクリプトは、コンテナー関連の OS 機能を有効にするように環境を構成し、Docker ランタイムもインストールされるお手軽仕様。
自動で再起動がかかる

再起動すると、プロンプトが起動し、インストールが再開される。

1
2
3
4
5
6
7
8
9
10
11
12
Querying status of Windows feature: Containers...
Feature Containers is already enabled.
DOCKER default
Checking Docker version
Downloading https://download.docker.com/win/static/stable/x86_64/docker-28.4.0.zip to C:\Users\Administrator\DockerDownloads\docker-28.4.0.zip
Installing Docker... C:\Users\Administrator\DockerDownloads\docker-28.4.0\docker\docker.exe
Installing Docker daemon... C:\Users\Administrator\DockerDownloads\docker-28.4.0\docker\dockerd.exe
Configuring the docker service...
Waiting for Docker daemon...
Successfully connected to Docker Daemon.
The following images are present on this machine:
REPOSITORY TAG IMAGE ID CREATED SIZE

無事にインストールされたので確認してみる。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$ docker info
Client:
Version: 28.4.0
Context: default
Debug Mode: false

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 2
Server Version: 28.4.0
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics internal l2bridge l2tunnel nat null overlay private transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local splunk syslog
CDI spec directories:
/etc/cdi
/var/run/cdi
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 20348 (20348.1.amd64fre.fe_release.210507-1500)
Operating System: Microsoft Windows Server Version 21H2 (OS Build 20348.587)
OSType: windows
Architecture: x86_64
CPUs: 2
Total Memory: 16GiB
Name: ESXI-VM19
ID: f48602e8-b9a2-4c4e-9e20-8853d0bdcaa0
Docker Root Dir: C:\ProgramData\docker
Debug Mode: false
Experimental: false
Insecure Registries:
::1/128
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

続いてコンテナを動かす。

hello-world

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4d91bcff7058: Pull complete
35bcc0a5ec2c: Pull complete
4b105737bfd4: Pull complete
Digest: sha256:54e66cc1dd1fcb1c3c58bd8017914dbed8701e2d8c74d9262e26bd9cc1642d31
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(windows-amd64, nanoserver-ltsc2022)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run a Windows Server container with:
PS C:\> docker run -it mcr.microsoft.com/windows/servercore:ltsc2022 powershell

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

Windows Nano Server

1
2
$ docker run --rm -it mcr.microsoft.com/windows/nanoserver:ltsc2022 cmd
> ver

左上がコンテナ、右下がホストマシン。

container

Ubuntu

動くわけありませんが…

1
2
3
4
5
6
$ docker run --rm -it ubuntu:24.04 /bin/bash
Unable to find image 'ubuntu:24.04' locally
24.04: Pulling from library/ubuntu
docker: no matching manifest for windows(10.0.20348)/amd64 in the manifest list entries

Run 'docker run --help' for more information