DockerFile을 이용하여 Image에 프로그램설치하기

1 분 소요

이번 포스트에서는

Dockerfile to image to container 2편에서 생성한 shw-aspnet4.8-website Image에

DevExpress를 설치하여 새로운 Image와 Container를 생성해 보도록 하겠다.

DockerFile 수정

Vhd to dockerfile 포스트에서 우리는 AddRemovePrograms Atifact를 통하여 DockerFile을 추출해 낸바 있다.

image-20191115221934392

이 DockerFile을 메모장으로 열어보자. 내용은 다음과 같다.

그런데 이게 뭔가 싶다. 아무것도 하는것이 없으니.. 추출되어 나온 프로그램추가제거 목록은 다 주석처리 되어있고 , 별다르게 하는 것이 없다.

# escape=`
FROM microsoft/windowsservercore:10.0.14393.1715
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# AddressBook
# Connection Manager
# DirectDrawEx
# DXM_Runtime
# Fontcore
# IE40
# IE4Data
# IE5BAKEX
# IEData
# MobileOptionPack
# MPlayer2
# Oracle VM VirtualBox Guest Additions
# SchedulingAgent
# WIC
# AddressBook
# Connection Manager
# DevExpress Components 16.2
# DirectDrawEx
# DXM_Runtime
# Fontcore
# IE40
# IE4Data
# IE5BAKEX
# IEData
# MobileOptionPack
# MPlayer2
# SchedulingAgent
# WIC

그래서 우리의 목표인 Image에 프로그램을 설치하기 위해서는 조금 DockerFile을 수정해 줘야한다.

수정된 내용

  • From Image 변경 : Dockerfile to image to container 2편에서 생성한 shw-aspnet4.8-website Image로 변경했다.

    #FROM microsoft/windowsservercore:10.0.14393.1715
    FROM shw-aspnet4.8-website:0.1
    
  • DockerFile이 위치한 곳에 DevExpressComponents-16.2.3.exe 설치파일을 복사해 놓고 Image의 C:\ 하위에 복사하도록 설정한다.

    image-20191121013106648

    COPY DevExpressComponents-16.2.3.exe C:\
    
  • Image가 생성될 때 DevExpressComponents-16.2.3가 Silent Mode로 설치되도록 설정한다.

    RUN powershell.exe -Command Start-Process 'C:\DevExpressComponents-16.2.3.exe' -ArgumentList '/Q, /EULA:accept'  -Wait
    

수정 후 DockerFile 전체 내용은 다음과 같다.

# escape=`
#FROM microsoft/windowsservercore:10.0.14393.1715
FROM shw-aspnet4.8-website:0.1
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

COPY DevExpressComponents-16.2.3.exe C:\
RUN powershell.exe -Command Start-Process 'C:\DevExpressComponents-16.2.3.exe' -ArgumentList '/Q, /EULA:accept'  -Wait

# AddressBook
# Connection Manager
# DirectDrawEx
# DXM_Runtime
# Fontcore
# IE40
# IE4Data
# IE5BAKEX
# IEData
# MobileOptionPack
# MPlayer2
# Oracle VM VirtualBox Guest Additions
# SchedulingAgent
# WIC
# AddressBook
# Connection Manager
# DevExpress Components 16.2
# DirectDrawEx
# DXM_Runtime
# Fontcore
# IE40
# IE4Data
# IE5BAKEX
# IEData
# MobileOptionPack
# MPlayer2
# SchedulingAgent
# WIC

이미지와 컨테이너 생성

#DockerFile이 있는 경로로 이동
cd D:\dockerfile_from_VHD\AddRemovePrograms2

#Image 생성
docker build -t shw-installpgm-devexpress3 --tag shw-installpgm-devexpress3:0.1 .

#Container 생성
docker run -it --name shw-installpgm-devexpress3-container shw-installpgm-devexpress3

image-20191121014056956

정상적으로 devexpress가 설치된 이미지가 생성되었고, w3svc가 활성화된 컨테이너가 올라왔다.

프로그램 설치여부 확인

# 컨테이너 내부로 진입
docker exec -i -t shw-installpgm-devexpress3-container powershell

# C:\Program Files (x86)\ 경로에 DevExpress 16.2 폴더가 생성되었는지 확인
dir "C:\Program Files (x86)\"

image-20191121014827952

DevExpress 16.2 폴더가 보인다. 프로그램이 Image에 설치 되었고 , 그 이미지에서 생성된 Container에서 설치된 프로그램을 확인할 수 있었다.

참고 URL

https://documentation.devexpress.com/GeneralInformation/15656/Installation/Install-DevExpress-NET-Products/Silent-Install-Mode

https://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/

댓글남기기