Windows 2019
Sponsored Link

Docker : Use Dockerfile
2019/02/19
 
Use Dockerfile and create Docker images automatically.
It is also useful for configuration management.
[1] For example, Create a Dockerfile to install IIS.
PS C:\Users\Administrator>
mkdir docker-test

PS C:\Users\Administrator\docker-test>
cd docker-test

PS C:\Users\Administrator\docker-test>
cat Dockerfile


# create a new file like follows with notepad or other text editor on GUI
FROM mcr.microsoft.com/windows/servercore:1809
MAINTAINER ServerWorld <admin@srv.world>

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

EXPOSE 80
CMD [ "cmd" ]

# build image ⇒ docker build -t [image name]:[tag] .

PS C:\Users\Administrator\docker-test>
docker build -t iis_server:latest .

Sending build context to Docker daemon  2.048kB
Step 1/6 : FROM mcr.microsoft.com/windows/servercore:1809
 ---> 640a8acbeb6f
Step 2/6 : MAINTAINER ServerWorld <admin@srv.world>
 ---> Running in 059576eb0100
Removing intermediate container 059576eb0100
 ---> 8d82163b2683
Step 3/6 : RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
 ---> Running in 17e24ac8c944
.....
.....
Successfully built 0ca3973f3882
Successfully tagged iis_server:latest

PS C:\Users\Administrator\docker-test>
docker images

REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
iis_server                             latest              0ca3973f3882        6 minutes ago       4.43GB
mcr.microsoft.com/windows/servercore   1809                640a8acbeb6f        6 days ago          4.28GB

# run Container on background

PS C:\Users\Administrator\docker-test>
docker run -t -d -p 8081:80 iis_server

780bf1b4db5942f6a10249195e4645e845d47656351e3dd84ddd240f2baef14e
PS C:\Users\Administrator\docker-test>
docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
780bf1b4db59        iis_server          "cmd"               17 seconds ago      Up 14 seconds       0.0.0.0:8081->80/tcp   wonderful_heyrovsky

# verify accesses

PS C:\Users\Administrator\docker-test>
curl.exe localhost:8081

Dockerfile test example
Matched Content
 
Tweet