본문 바로가기
IT/Docker

Docker on windows (윈도우에서 도커 사용)

by Aeyoung na 2018. 7. 16.

이번 포스팅은 윈도우 서버에서 도커를 실행하는 방법에대해 다뤄보았습니다






Windows Server 2016 부터 Windows container 와 hyper-v container 형태의 컨테이너 기술 Docker 를 지원합니다 (Windows Server 2016 TP3 이상)


참고자료 


iis실행 예제 : https://msdn.microsoft.com/ko-kr/virtualization/windowscontainers/quick_start/manage_docker

docker와 power shell 명령어 비교: https://msdn.microsoft.com/ko-kr/virtualization/windowscontainers/reference/ps_docker_comparison

windows container 기술 정리 : https://blogs.technet.microsoft.com/koalra/2015/08/28/microsoft-container-windows-server-2016-docker-indowshyper-v-container/




테스트 환경 (docker engine, container): Virtualbox + Windows Server 2016 TP4)


.PS C:\Users\halizy\docker> docker info


Containers: 0


Images: 9


Server Version: 1.10.0-dev


Storage Driver: windowsfilter


 Windows:


Execution Driver:


 Name: Windows 1854


 Build: 1.10.0-dev 18c9fe0


 Default Isolation: process


Logging Driver: json-file


Plugins:


 Volume: local


 Network:


Kernel Version: 10.0 10586 (10586.162.amd64fre.th2_release_sec.160223-1728)


Operating System: Windows Server 2016 Technical Preview 4


OSType: windows


Architecture: x86_64


CPUs: 1


Total Memory: 2 GiB


Name: WIN-LSO256AIBAL


ID: OPQ7:MAVJ:RHFL:HF7Z:JNZE:X7Y7:XANQ:IJGP:3SF7:WSHY:ABLR:XH3U


Debug mode (server): true


 File Descriptors: -1


 Goroutines: 16


 System Time: 2019-07-21T11:41:12.0247248+09:00


 EventsListeners: 0


 Init SHA1:


 Init Path: C:\Windows\System32\docker.exe


 Docker Root Dir: C:\ProgramData\docker




테스트 내용 :IIS in Docker , .NET Framework in Docker 컨테이너 실행

IIS in Docker

# Powershell 을 이용해 Dockfile 생성

> mkdir docker/iisdemo
> cd docker/iisdemo
> notepad Dockerfile
 
FROM microsoft/iis
 
RUN echo " Hello World From a Windows Server Container" > c:\inetpub\wwwroot\index.html 




# 이미지 build
  
> docker build -t demo/iisindocker C:\Users\halizy\docker\

Sending build context to Docker daemon 2.048 kB

Step 1 : FROM microsoft/iis

 ---> 39b8f98ccaf1

Step 2 : RUN echo " Hello World From a Windows Server Container" > c:\inetpub\wwwroot\index.html

 ---> Running in e0efe4b542cc

 ---> c5194c8468c4

Removing intermediate container e0efe4b542cc

Successfully built c5194c8468c4
 
> docker images

REPOSITORY    TAG  IMAGE ID  CREATED VIRTUAL SIZE
demo/iisindocker latest   c5194c8468c4   2 hours ago      178 MB







# Container 실행

> docker run --name iisdemo -it  -p 80:80 demo/iisindocker cmd



웹페이지 접속



C#.NET Framework in Docker


# test C# file build

> notepad program.cs
 
 
using System.IO;
using System;
 
 
class Program
{
    static void Main()
    {
        Console.WriteLine("Hello World in docker container using dotnet");
 
 
        Console.WriteLine("After 30sec, Program is going down");
        System.Threading.Thread.Sleep(30000);
    }
}
 
 
> mcs program.cs -out:program.exe


# Powershell 을 이용해 Dockfile 생성

> notepad C:\users\halizy\docker\dotnetdemo\Dockerfile
 
FROM microsoft/dotnet35

ADD ./program.exe /program.exe

RUN /program.exe



# 이미지 build 하기

> docker build -t demo/dotnet35 c:\Users\halizy\docker\dotnetdemo

> docker images 

REPOSITORY    TAG  IMAGE ID  CREATED VIRTUAL SIZE
demo/dotnet35 latest   7c0d91a3ce4c  2 minutes ago      869 MB




# Container 실행

docker run -it demo/dotnet35 /program.exe

Hello World in docker container using dotnet

After 30sec, Program is going down
 





댓글