ノート: GitHubホストランナーは、現在GitHub Enterprise Serverでサポートされていません。 GitHubパブリックロードマップで、計画されている将来のサポートに関する詳しい情� �を見ることができます。
概要
Use jobs.<job_id>.container to create a container to run any steps in a job that don't already specify a container. スクリプトアクションとコンテナアクションの両方を使うステップがある� �合、コンテナアクションは同じボリュー� マウントを使用して、同じネットワーク上にある兄弟コンテナとして実行されます。
containerを設定しない� �合は、コンテナで実行されるよう設定されているアクションを参照しているステップを除くすべてのステップが、runs-onで指定したホストで直接実行されます。
Example: Running a job within a container
name: CI
on:
  push:
    branches: [ main ]
jobs:
  container-test-job:
    runs-on: ubuntu-latest
    container:
      image: node:14.16
      env:
        NODE_ENV: development
      ports:
        - 80
      volumes:
        - my_docker_volume:/volume_mount
      options: --cpus 1
    steps:
      - name: Check for dockerenv file
        run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)コンテナイメージのみを指定する� �合、imageは省略できます。
jobs:
  container-test-job:
    runs-on: ubuntu-latest
    container: node:14.16
Defining the container image
Use jobs.<job_id>.container.image to define the Docker image to use as the container to run the action. The value can be the Docker Hub image name or a registry name.
Defining credentials for a container registry
If the image's container registry requires authentication to pull the image, you can use jobs.<job_id>.container.credentials to set a map of the username and password. この認証情� �は、docker loginコマンドに渡すものと同じ値です。
Example: Defining credentials for a container registry
container:
  image: ghcr.io/owner/image
  credentials:
     username: ${{ github.actor }}
     password: ${{ secrets.github_token }}
Using environment variables with a container
Use jobs.<job_id>.container.env to set a map of environment variables in the container.
Exposing network ports on a container
Use jobs.<job_id>.container.ports to set an array of ports to expose on the container.
Mounting volumes in a container
Use jobs.<job_id>.container.volumes to set an array of volumes for the container to use. volumes (ボリュー� ) を使用すると、サービス間で、または1つのジョブのステップ間でデータを共有できます。 指定できるのは、名前付きDockerボリュー� 、匿名Dockerボリュー� 、またはホスト上のバインドマウントです。
ボリュー� を指定するには、ソースパスとターゲットパスを指定してく� さい。
<source>:<destinationPath>.
<source>は、ホストマシン上のボリュー� 名または絶対パス、<destinationPath>はコンテナでの絶対パスです。
Example: Mounting volumes in a container
volumes:
  - my_docker_volume:/volume_mount
  - /data/my_data
  - /source/directory:/destination/directory
Setting container resource options
Use jobs.<job_id>.container.options to configure additional Docker container resource options. オプションの一覧は、「docker createのオプション」を参照してく� さい。
Warning: The --network option is not supported.