Windows 2025
Sponsored Link

Docker : Basic Usage2024/12/16

 

This is the Basic Usage of Docker.
Run PowerShell or Command Prompt to use it.

[1]

Download Windows official image and run [echo] inside a Container.

It's impossible to run Containers if the Version of Host Windows and Container Windows are not the same one,
so specify a specific version when pulling an image. Refer to the official documents below for version compatibility.

⇒ https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2025%2Cwindows-11

You can find the catalog of container images on the following site.

⇒ https://mcr.microsoft.com/v2/_catalog

You can find the tag list of a specific container images on the following site.

⇒ https://mcr.microsoft.com/v2/(namespace)/(repo)/tags/list
ex : https://mcr.microsoft.com/v2/windows/servercore/tags/list
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# pull Windows ServerCore image
PS C:\Users\Administrator> docker pull mcr.microsoft.com/windows/servercore:ltsc2025 
ltsc2025: Pulling from windows/servercore
73f0ab5f3568: Pull complete
Digest: sha256:a15aa8b1386ab9edc262df05978fc8894a6b1cd7bdb511eff94db768f1b26a9c
Status: Downloaded newer image for mcr.microsoft.com/windows/servercore:ltsc2025
mcr.microsoft.com/windows/servercore:ltsc2025

# display images
PS C:\Users\Administrator> docker images 
REPOSITORY                             TAG        IMAGE ID       CREATED      SIZE
mcr.microsoft.com/windows/servercore   ltsc2025   f9fb7d5c26c9   7 days ago   5.14GB

# run echo inside a container
PS C:\Users\Administrator> docker run mcr.microsoft.com/windows/servercore:ltsc2025 powershell -c "echo 'Hello Windows Container World'" 
Hello Windows Container World
[2] Connect to the interactive session of a Container with [i] and [t] option like follows.
If [exit] from the Container session, the process of a Container finishes.
PS C:\Users\Administrator> docker run -it mcr.microsoft.com/windows/servercore:ltsc2025 powershell 

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\> systeminfo 

Host Name:                     B36FBAD1A360
OS Name:                       Microsoft Windows Server 2025 Datacenter
OS Version:                    10.0.26100 N/A Build 26100
OS Manufacturer:               Microsoft Corporation
OS Configuration:              Standalone Server
OS Build Type:                 Multiprocessor Free
Registered Owner:              N/A
Registered Organization:       N/A
Product ID:                    00491-50000-00001-AA917
Original Install Date:         12/8/2024, 10:42:19 PM
System Boot Time:              12/15/2024, 5:27:13 PM
System Manufacturer:           Red Hat
System Model:                  KVM
System Type:                   x64-based PC
Processor(s):                  8 Processor(s) Installed.
                               [01]: Intel64 Family 6 Model 106 Stepping 6 GenuineIntel ~2400 Mhz
                               [02]: Intel64 Family 6 Model 106 Stepping 6 GenuineIntel ~2400 Mhz
.....
.....

PS C:\> exit 
PS C:\Users\Administrator>    # come back
[3] If you'd like to run a Container as a Daemon, add [d] option.
PS C:\Users\Administrator> docker run -itd mcr.microsoft.com/windows/servercore:ltsc2025 powershell 
bf098c12220dc9ad932fb9d3edb95d3e276865a1fff73c7cbfc6fb404c94d02c

PS C:\Users\Administrator> docker ps 
CONTAINER ID   IMAGE                                           COMMAND        CREATED              STATUS              PORTS     NAMES
bf098c12220d   mcr.microsoft.com/windows/servercore:ltsc2025   "powershell"   About a minute ago   Up About a minute             affectionate_lehmann

# connect to container's session
PS C:\Users\Administrator> docker attach bf098c12220d 

PS C:\> hostname 
bf098c12220d
PS C:\> exit 

# shutdown container's process from Host's console
PS C:\Users\Administrator> docker kill bf098c12220d 
bf098c12220d

PS C:\Users\Administrator> docker ps 
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
Matched Content