Windows 2022
Sponsored Link

Docker : Use Dockerfile
Use Dockerfile and create Docker images automatically.
It is also useful for configuration management.
[1] For example, Create a Dockerfile to install IIS.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> mkdir docker-file 
PS C:\Users\Administrator\docker-file> cd docker-file 

# create Dockerfile
PS C:\Users\Administrator\docker-file> $str_file = @"
MAINTAINER ServerWorld <>

RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
RUN echo Dockerfile test example > C:\inetpub\wwwroot\index.html

CMD [ "cmd" ]

PS C:\Users\Administrator\docker-file> $str_file | Out-File Dockerfile -Encoding Default 

# build image ⇒ docker build -t [image name]:[tag] . 
PS C:\Users\Administrator\docker-test> docker build -t . 
Sending build context to Docker daemon  2.048kB
Step 1/6 : FROM
 ---> 11cbc9e36c7a
Step 2/6 : MAINTAINER ServerWorld <>
 ---> Running in c775d6cedbb1
Removing intermediate container c775d6cedbb1
 ---> 05582598eefe
Step 3/6 : RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
 ---> Running in c92f3ef1c94e


Step 6/6 : CMD [ "cmd" ]
 ---> Running in b7c3e38a4740
Removing intermediate container b7c3e38a4740
 ---> 0eaa2396d003
Successfully built 0eaa2396d003
Successfully tagged

PS C:\Users\Administrator\docker-test> docker images 
REPOSITORY                             TAG        IMAGE ID       CREATED          SIZE                   latest     0eaa2396d003   2 minutes ago    5.07GB   ltsc2022   11cbc9e36c7a   4 days ago       4.95GB

# run Container on background
PS C:\Users\Administrator\docker-test> docker run -dt -p 8081:80 

PS C:\Users\Administrator\docker-test> docker ps 
CONTAINER ID   IMAGE                  COMMAND   CREATED          STATUS          PORTS                  NAMES
bb75b4501071   "cmd"     29 seconds ago   Up 28 seconds>80/tcp   condescending_darwin

# verify accesses
PS C:\Users\Administrator\docker-test> curl.exe localhost:8081 
Dockerfile test example
Matched Content