Migrate to Containers CLI を使用すると、Linux ベースのアプリケーションをコンテナ化された環境に移行できます。モダナイズされたアプリケーションに必要なサービスのブートローダーとして機能する、ビルド済みの Linux システム コンテナを使用します。Migrate to Containers for Linux アプリケーションを使用すると、Google Kubernetes Engine(GKE)、Cloud Run、GKE クラスタで実行するさまざまなステートレス アプリケーションをモダナイズできます。
このドキュメントでは、Migrate to Containers を使用して移行されたアプリケーションを実行するためのソリューションで使用される Migrate to Containers Linux システム コンテナについて詳しく説明します。
Linux システム コンテナを使用した移行
Migrate to Containers は、ソース アプリケーションのファイルとプロセスを検出します。次に、Dockerfile、Kubernetes マニフェスト、Skaffold 構成を含むアーティファクトを生成します。
Linux システム コンテナの主な機能は、関連するオペレーティング システムやアプリケーション サービスなど、元々ソース仮想マシン(VM)インスタンスで実行されていたサービスを開始することです。
Dockerfile は、移行された VM のイメージのビルドに使用されます。通常、Linux システム コンテナの Dockerfile は次のようになります。
# Please refer to the documentation:
# https://cloud.google.com/migrate/anthos/docs/dockerfile-reference
FROM us-docker.pkg.dev/migrate-modernize-public/modernize-plugins-prod/service-manager-runtime:1.0.0 as service-manager-runtime
FROM scratch
# Tar containing data captured from the source VM
ADD vmFiles.tar.gz /
COPY --from=service-manager-runtime / /
ADD blocklist.yaml /.m4a/blocklist.yaml
ADD logs.yaml /code/config/logs/logsArtifact.yaml
ADD services-config.yaml /.m4a/
ADD tempfiles.yaml /.m4a/
# If you want to update parts of the image, add your commands here.
# For example:
# RUN apt-get update
# RUN apt-get install -y \
# package1=version \
# package2=version \
# package3=version
# RUN yum update
# RUN wget http://github.com
ENTRYPOINT ["/ko-app/service-manager-runtime", "start", "-c", "/.m4a/"]
移行を実行すると、次の Dockerfile ステートメントによって、元のソースから Docker イメージに VM データがコピーまたは追加されます。
次のステートメントは、ソース VM から取得したデータを含む tar ファイルを Docker イメージに追加します。
ADD vmFiles.tar.gz /
この tar は Migrate to Containers によって作成されます。これには、移行元 VM のルート ファイル システムと、移行計画のフィルタで指定されたすべての内容、データ移行計画で除外されたフォルダが含まれています。
次のステートメントは、Migrate to Containers ランタイムを Docker リポジトリから Docker イメージにインポートします。
FROM us-docker.pkg.dev/migrate-modernize-public/modernize-plugins-prod/service-manager-runtime:1.0.0 as service-manager-runtime
次のステートメントは、Migrate to Containers ランタイムを Docker イメージにコピーします。
COPY --from=service-manager-runtime / /
クリックすると Migrate to Containers ランタイム ファイルの詳細が表示されます
/ko-app/service-manager-runtime は、Migrate to Containers のメイン ランタイム ファイルです。これは、コンテナ用に作成された初期化システムです。この処理内容は次のとおりです。
移行したアーティファクトから、アプリケーションの新しいパイプラインを作成できます。アプリケーションごとに異なるパイプラインを使用できます。元の VM ベースのアプリケーションを生成した既存の継続的インテグレーションとデプロイのパイプラインを維持し、生成された実行可能ファイルを Linux システム コンテナに変換する関連ステップを追加できます。
次の図は、Migrate to Containers を使用したサンプル パイプラインを示しています。
この図は、既存のアプリケーションの変更プロセスを示しています。
ソースコードまたは新しい OS パスの変更が既存の Git リポジトリに push されます。ソースが既存の設定に基づいてコンパイルされ、新しいイメージがビルドされます。新しいイメージには、Migrate to Containers ランタイム レイヤが含まれています。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[],[],null,["# About Linux system containers\n=============================\n\nThe Migrate to Containers CLI lets you migrate Linux-based applications to\ncontainerized environments. It uses a prebuilt Linux system container that\nfunctions as a bootloader for the services required by the modernized\napplication. Using Migrate to Containers for Linux applications, you can modernize a\nwide range of stateless applications to run on Google Kubernetes Engine (GKE),\nCloud Run, and GKE clusters.\n\nFor more information, see [Migrate to Containers CLI architecture](/migrate/containers/docs/m2c-cli/architecture).\n\nThis document provides details about Migrate to Containers Linux system containers\nthat are used as a part of the solution for running applications migrated using\nMigrate to Containers.\n\nMigration using Linux system container\n--------------------------------------\n\nMigrate to Containers discovers the source application files and processes. It then\ngenerates artifacts which include a Dockerfile, Kubernetes manifest, and\nSkaffold configuration.\n\nThe main function of a Linux system container is to initiate the services that\nwere originally run at the source virtual machine (VM) instance, including\nrelevant operating system and application services.\n\nThe Dockerfile is used to build the image for your migrated VM. A Linux system\ncontainer Dockerfile usually looks similar to the following: \n\n # Please refer to the documentation:\n # https://cloud.google.com/migrate/anthos/docs/dockerfile-reference\n\n FROM us-docker.pkg.dev/migrate-modernize-public/modernize-plugins-prod/service-manager-runtime:1.0.0 as service-manager-runtime\n\n FROM scratch\n\n # Tar containing data captured from the source VM\n ADD vmFiles.tar.gz /\n\n COPY --from=service-manager-runtime / /\n\n ADD blocklist.yaml /.m4a/blocklist.yaml\n\n ADD logs.yaml /code/config/logs/logsArtifact.yaml\n\n ADD services-config.yaml /.m4a/\n\n ADD tempfiles.yaml /.m4a/\n\n # If you want to update parts of the image, add your commands here.\n # For example:\n # RUN apt-get update\n # RUN apt-get install -y \\\n # package1=version \\\n # package2=version \\\n # package3=version\n # RUN yum update\n # RUN wget http://github.com\n\n ENTRYPOINT [\"/ko-app/service-manager-runtime\", \"start\", \"-c\", \"/.m4a/\"]\n\nWhen you execute a migration, the following Dockerfile statements copy or add\nthe VM data from the original source to the Docker image:\n\n- The following statement adds the tar file that contains the data captured\n from the source VM to the Docker image:\n\n ADD vmFiles.tar.gz /\n\n This tar is created by Migrate to Containers. It contains the root file system of\n the source VM with everything provided in filters in the migration plan and\n any folder provided in the data migration plan filtered out.\n- The following statement imports the Migrate to Containers runtime from the Docker\n repository into the Docker image:\n\n FROM us-docker.pkg.dev/migrate-modernize-public/modernize-plugins-prod/service-manager-runtime:1.0.0 as service-manager-runtime\n\n- The following statement then copies the Migrate to Containers runtime into the\n Docker image:\n\n COPY --from=service-manager-runtime / /\n\n#### Click to view details about the Migrate to Containers runtime file\n\n`/ko-app/service-manager-runtime` is the main Migrate to Containers\nruntime file. This is an initialization system that is made for containers. It\ndoes the following:\n\n- Reads the `/.m4a/services-config.yaml` file, and runs the specified binaries in order according to the specified run method such as daemonize, not daemonize, wait for finish.\n- Collects logs specified in the `/code/config/logs/logsArtifact.yaml` file and prints them to `stdout` of the container. For GKE and GKE clusters, it also ensures that the logs are sent to Cloud Logging.\n\nMaintenance of migrated workloads\n---------------------------------\n\nYou can create a new pipeline for your application from the migrated artifacts.\nYou might have a different pipeline for different applications. You can keep\nyour existing continuous integration and deployment pipeline which\ngenerated the original VM-based application, and add the relevant steps that\ntransform the generated executables into Linux system containers.\n\nThe following diagram illustrates a sample pipeline using Migrate to Containers:\n\nThis diagram shows the change process of an existing application.\n\nA change to source code or new OS path is pushed to the existing Git\nrepository. The source is compiled based on the existing setup and a new image\nis built. The new image includes the Migrate to Containers runtime layer.\n\nIn the test environment, a developer runs preliminary tests to confirm\nwhether the new image is working as expected. After the test phase, a new\nsystem container image is created and pushed to the development or test\nenvironment, which is later rolled out to production."]]