本トピックには、Hello World Docker デモンストレーションの Dockerfile.dn ファイルのリストおよび説明が含まれています。Dockerfile 全体をリストし、Dockerfile に含まれる各コマンドの説明をその後の表にまとめてあります。Dockerfile のリストに示してある行番号は、読みやすくするために追加したものです。付属の Dockerfile には記載されていません。
001 # Copyright (C) Micro Focus 2018. All rights reserved.
002 # This sample code is supplied for demonstration purposes only
003 # on an "as is" basis and is for use at your own risk.
004
005 ARG MFPRODBASE=
006 ARG DTAG=win_4.0
007 FROM microfocus/vcbuildtools-build:${DTAG} as build-env
008
009 LABEL com.microfocus.is-example="true"
010
011 ARG Platform=AnyCPU
012 ARG Config=Release
013
014 # Copy the src folder to c:\src in the container
015 COPY src "c:\\src"
016 WORKDIR "c:\\src"
017
018 # build source using the msbuild project with a output directory of c\app
019 ENV BLDPlatform ${Platform}
020 ENV BLDConfig ${Config}
021 RUN msbuild /p:OutDir=c:\app /p:Configuration=%BLDConfig%;Platform=%BLDPlatform% DNHelloWorld.cblproj
022
023 # Build runtime image for development or production
024 FROM ${MFPRODBASE}
025 WORKDIR "c:\\app"
026 COPY --from=build-env "c:\\app" "c:\\app"
027 ENTRYPOINT ["DNHelloWorld.exe"]
The commands on the lines in this Dockerfile are as follows:
| 行 | 説明 |
|---|---|
| 005 | Defines the MFPRODBASE build argument passed by the
docker build command. This argument specifies the Visual COBOL base image for use later in this Dockerfile. |
| 006 - 007 | Specifies that the base image to use is the "build" version of the Visual COBOL base image, and gives the name "build-env" for this build stage. |
| 009 | 作成するイメージのメタデータ ラベルを指定します。これらのラベルは docker inspect コマンドで照会できます。 |
| 011 - 012 | docker build コマンドで渡すビルド引数を定義します。
|
| 015 - 016 | Copy the Hello World source files to a folder in the image's filesystem and set this folder to be the Docker working directory. |
| 019 - 021 | Build the Hello World application, putting the build output in c:\app. |
| 024 | Specifies the start of a new build stage that uses the Visual COBOL base image (as specified by the MFPRODBASE) build argument). |
| 025 - 026 | Sets the Docker working directory to be c:\app then copies the files from the "build-env" build stage into it. |
| 027 | Specifies that running the image runs the Hello World application. |