本トピックには、Hello World Docker デモンストレーションの Dockerfile ファイルのリストおよび説明が含まれています。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 # use the -build image, as we are using msbuild 006 ARG MFPRODBASE= 007 ARG DTAG= 008 FROM microfocus/vcbuildtools-build:${DTAG} as build-env 009 010 LABEL com.microfocus.is-example="true" 011 ARG Config=Release 012 013 # Copy the src folder to c:\src in the container 014 COPY src "c:\\src" 015 WORKDIR "c:\\src" 016 017 # Build the source using the msbuild project file with a output directory of c:\app 018 ARG Platform=x86 019 ENV BLDPlatform ${Platform} 020 ENV BLDConfig ${Config} 021 RUN msbuild /p:OutDir=c:\app /p:Configuration=%BLDConfig%;Platform=%BLDPlatform% HelloWorld.sln 022 023 # Build runtime image for development or production 024 FROM ${MFPRODBASE} 025 WORKDIR "c:\\app" 026 027 # Copy the c:\app folder from the build-env step 028 COPY --from=build-env "c:\\app" "c:\\app" 029 ENTRYPOINT ["HelloWorld.exe"]
The commands on the lines in this Dockerfile are as follows:
行 | 説明 |
---|---|
006 から 008 | Visual COBOL ベース イメージの「-build」バージョンをベース イメージとして使用するように指定し、このビルド ステージに「build-env」という名前を付けます。 |
010 | 作成するイメージのメタデータ ラベルを指定します。これらのラベルは docker inspect コマンドで照会できます。 |
011 | docker build コマンドで渡すビルド引数を定義します。 Config は、ビルド時に使用する Configuration プロパティを指定します。 |
014 から 015 | Copy the Hello World source files to a folder in the image's filesystem and set this folder to be the Docker working directory. |
018 | docker build コマンドで渡すビルド引数を定義します。 Platform は、ビルド時に使用する Platform プロパティを指定します。 |
019 から 020 | 環境変数を作成して、Platform ビルド引数および Config ビルド引数の値に設定します。 |
021 | Build the Hello World application, putting the build output in c:\app. |
024 | Visual COBOL ベース イメージ (MFPRODBASE ビルド引数によって指定される) を使用する新しいビルド ステージの開始を指定します。 |
025 から 028 | Docker の作業ディレクトリを c:\app に設定し、そこに「build-env」ビルド ステージのファイルをコピーします。 |
029 | Specifies that running the image runs the Hello World application. |