Completek8s Classroomnotes 16/Jul/2023

Containers on Windows

  • Lets build a windows container
    • Lets create an iis server and copy the html file index.html
  • manual steps
docker container run -it -p 80 --name trail mcr.microsoft.com/windows/servercore:ltsc2022 powershell
Install-WindowsFeature -name Web-Server -IncludeManagementTools
  • The basic Dockerfile
FROM mcr.microsoft.com/windows/servercore:ltsc2022
LABEL author=khaja
RUN ["powershell", "Install-WindowsFeature", "-name",  "Web-Server",  "-IncludeManagementTools"]
EXPOSE 80
ADD index.html C:/inetpub/wwwroot
CMD ["cmd.exe"]
  • build the image and run the continer
  • If you want to run the .net framework images Refer Here for sdk images
  • aspnet docker images Refer Here
  • I have pulled
docker pull mcr.microsoft.com/dotnet/framework/sdk:4.8.1
docker pull mcr.microsoft.com/dotnet/framework/aspnet:4.8.1
  • Multistage dotnet build
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8.1 As builder

WORKDIR c:/src/MusicStore
COPY . C:/src/MusicStore
RUN nuget restore MvcMusicStore/packages.config -SolutionDirectory .
RUN msbuild MvcMusicStore.sln /p:OutputPath:c:\out /p:Configuration:Release

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8.1
COPY --from=builder C:\out\_PublishedWebsites\MvcMusicStore C:\MvcMusicStore
RUN New-WebSite -Name "MvcMusicStore" -Port 80 -HostHeader "MvcMusicStore" -PhysicalPath "C:\MvcMusicStore"
EXPOSE 80
  • Lets deal with volumes in windows
  • pull the image mcr.microsoft.com/windows/nanoserver:1809
docker image pull mcr.microsoft.com/windows/nanoserver:1809
  • Create a simple Docker file
FROM mcr.microsoft.com/windows/nanoserver:1809

VOLUME c:\app\logs
USER ContainerAdminstrator
ENTRYPOINT cmd /S /C

Docker Registries

  • Create a spring petclinic docker image on a linux instance
  • Build the image
  • Docker images are stored in registries.
  • Each registry will have multiple repositories
  • Each repository can store multipe tags of the docker image
  • The default docker registry is docker hub
  • Repository name => username/reponame
    Preview
  • specific image => Repo:tag => username/repo:tag
  • After building the image tag the image with new naming format docker image tag spc:latest shaikkhajaibrahim/spcjuly23:2.4.2-jdk11

Docker hub

  • To connect to docker hub
docker login

Preview
* now push the image

docker image push shaikkhajaibrahim/spcjuly23:2.4.2-jdk11

Preview
* Refer Here for image info
* Now anyone connected to docker hub can run this application

docker container run -d -P --name spc1 shaikkhajaibrahim/spcjuly23:2.4.2-jdk11

Exercise

  • Try pushing your images to
    • docker hub
    • aws ecr
    • azure acr

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner