Bitbucket is getting a new navigation

We’re rolling out these changes, so the documentation may not match your experience in the Bitbucket Cloud app. Read about the new Bitbucket navigation

Docker イメージ オプション

Bitbucket Pipelines runs most builds in Docker containers (excluding builds on the Linux shell, macOS, and Windows runners). The image options allow you to use custom Docker images as build environments. Most of these options relate to pulling images from private Docker registries.

Docker Hub、AWS、GCP、Azure、インターネットでアクセス可能な自社ホスト型レジストリにホストされる、公開または非公開の Docker イメージをサポートしています。現在、Bitbucket Pipelines では、インターネット経由でアクセスできない Docker イメージにはアクセスできません。

For details on using custom Docker images with Bitbucket Pipelines, see Use Docker images as build environments.

Docker イメージ オプション

The following options can be used to set the Docker image for pipeline steps globally within a bitbucket-pipelines.yml, for individual steps, or for service containers:

画像

Bitbucket Pipelines は、次のいずれかの場所におけるビルドの実行時に Docker コンテナーを使用します。

  • Bitbucket Cloud のインフラストラクチャ上、または

  • Linux Docker の自社ホスト ランナー上。

You can use the ‘Recommended’ default image provided by Bitbucket or define a custom image. You can specify any public or private Docker image that isn't hosted on a private network. The image used can be set at the global level, and overridden for individual steps.

image オプションは、公開のイメージまたは非公開のイメージを指定するために使用できます。一般にアクセス可能な Docker イメージの場合は、次のような単一行のオプションとして image を使用できます。

image: atlassian/default-image:IMAGE_TAG_HERE

非公開イメージの場合は、次のような image オプションのブロック バージョンをご利用ください。

image: name: us-east1-docker.pkg.dev/my-project/my-repo/test-image:latest username: $DOCKER_REGISTRY_USERNAME password: $DOCKER_REGISTRY_PASSWORD

For information about using and creating images, see Use Docker images as build environments.

プロパティimage

必須 — いいえ

データ タイプ — 次のいずれか:

Default valueatlassian/default-image:latest (For details, see Use Docker images as build environments — Default build environment)

Allowed parent propertiesservices, step, or the YAML root (image can be a top-level property)

Allowed child propertiesname, username, password, aws, and run-as-user

例 — image オプションを使用して、パイプライン全体のイメージを設定する

image: bash:latest # https://hub.docker.com/_/bash pipelines: default: - step: name: Hello world example script: - echo "Hello, World!"

例 — image オプションを使用して、パイプライン ステップで別のイメージを使用する

image: bash:latest # https://hub.docker.com/_/bash pipelines: default: - step: name: Step using the Bash image script: - bash --version - step: name: Step using the default Bitbucket Pipelines image image: atlassian/default-image:latest # https://hub.docker.com/r/atlassian/default-image/ script: - echo "Hello, World from the default Pipelines image"

例 — Docker Hub 外でホストされている公開イメージを使用する

image: public.ecr.aws/docker/library/python:slim # https://gallery.ecr.aws/docker/library/python pipelines: default: - step: name: Step using the Python image script: - echo "Python version:" $(python --version) - step: name: Step using the default Bitbucket Pipelines image image: atlassian/default-image:latest # https://hub.docker.com/r/atlassian/default-image/ script: - echo "Node.js version:" $(node -v)

例 — 非公開イメージを使用する

この例は、Docker Hub から非公開イメージを取得する方法を示しています (実際の使用方法は、Docker Hub の認証メソッドによって異なる場合があります)。

image: name: my-docker-hub-account/my-docker-image:latest username: $DOCKER_HUB_USERNAME password: $DOCKER_HUB_PASSWORD run-as-user: 1001 pipelines: default: - step: name: Hello world example script: - echo "Hello, World!"

この例は、Docker Hub 以外のイメージ リポジトリ (この場合は Google Artifact Registry) から非公開イメージを取得する方法を示しています。

image: name: us-east1-docker.pkg.dev/my-project/my-repo/test-image:latest username: $DOCKER_REGISTRY_USERNAME password: $DOCKER_REGISTRY_PASSWORD pipelines: default: - step: name: Hello world example script: - echo "Hello, World!"

名前

The image name property is used to specify which Docker image to use when you are using a private image and login credentials are required. For details on configuring access to private Docker images, see Use Docker images as build environments — Using private build images.

プロパティname

必須 — いいえ

データ タイプ — 文字列

Allowed parent propertiesimage

例 — name を使用して、公開されている DockerHub イメージを取得する

image: name: my-account/bash:latest pipelines: default: - step: script: - echo "Hello, World!"

例 — name を使用して、ステップで使用するイメージを上書きする

image: my/bash:lts pipelines: default: - step: image: name: my/bash:latest script: - echo "Hello, World!"

例 — name を使用して、サービス コンテナーに使用するイメージを設定する

definitions: services: my-service: image: name: my/bash:latest pipelines: default: - step: services: - my-service script: - echo "Hello, World!"

ユーザ名

The image username property, when used with the password property, provides Bitbucket Pipelines with access to private Docker images. For details on configuring access to private Docker images, see Use Docker images as build environments — Using private build images.

Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.

プロパティusername

必須 — いいえ

データ タイプ — 文字列

Allowed parent propertiesimage

例 — username と password を使用して、非公開 Docker イメージを取得する

image: name: my/bash:latest username: $CONTAINER_REGISTRY_USERNAME password: $CONTAINER_REGISTRY_PASSWORD pipelines: default: - step: script: - echo "Hello, World!"

例 — username と password を使用して、ステップに使用したビルド イメージを非公開イメージでオーバーライドする

image: my/bash:lts pipelines: default: - step: image: name: my/bash:latest username: $CONTAINER_REGISTRY_USERNAME password: $CONTAINER_REGISTRY_PASSWORD script: - echo "Hello, World!"

例 — username と password を使用して、非公開イメージを使用するサービス コンテナーを定義する

definitions: services: my-service: image: name: my/bash:latest username: $CONTAINER_REGISTRY_USERNAME password: $CONTAINER_REGISTRY_PASSWORD pipelines: default: - step: services: - my-service script: - echo "Hello, World!"

パスワード

The image password property, when used with the username property, provides Bitbucket Pipelines with access to private Docker images. For details on configuring access to private Docker images, see Use Docker images as build environments — Using private build images.

Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.

プロパティpassword

必須 — いいえ

データ タイプ — 文字列

Allowed parent propertiesimage

例 — password と username を使用して、非公開 Docker イメージを取得する

image: name: my/bash:latest username: $CONTAINER_REGISTRY_USERNAME password: $CONTAINER_REGISTRY_PASSWORD pipelines: default: - step: script: - echo "Hello, World!"

例 — password と username を使用して、ステップに使用したビルド イメージを非公開イメージで上書きする

image: my/bash:lts pipelines: default: - step: image: name: my/bash:latest username: $CONTAINER_REGISTRY_USERNAME password: $CONTAINER_REGISTRY_PASSWORD script: - echo "Hello, World!"

例 — password と username を使用して、非公開イメージを使用するサービス コンテナーを定義する

definitions: services: my-service: image: name: my/bash:latest username: $CONTAINER_REGISTRY_USERNAME password: $CONTAINER_REGISTRY_PASSWORD pipelines: default: - step: services: - my-service script: - echo "Hello, World!"

ユーザーとして起動

イメージの既定ユーザーは、run-as-user プロパティでユーザー UID を指定することでオーバーライドできます。指定されたユーザー UID は、イメージですでに定義されているユーザーであり、有効なホーム ディレクトリを持っている必要があります。

プロパティrun-as-user

必須 — いいえ

データ タイプ — 整数

指定可能な値 — イメージ上の任意のユーザーの UID

既定値0 (ルート ユーザー)

Allowed parent propertiesimage

例 — run-as-user を使用して、特定のユーザーとしてパイプライン ステップを実行する (UID = 1000)

image: name: my/bash:latest run-as-user: 1000 pipelines: default: - step: script: - echo "Hello, World!"

例 — run-as-user を使用して、特定のユーザーとして 1 つのパイプライン ステップを実行する (UID = 1000)

image: my/bash:lts pipelines: default: - step: image: name: my/bash:lts run-as-user: 1000 script: - echo "Hello, World!"

例 — run-as-user を使用して、特定のユーザーとして 1 つのサービス コンテナーを実行する (UID = 1000)

definitions: services: my-service: image: name: my/bash:latest run-as-user: 1000 pipelines: default: - step: services: - my-service script: - echo "Hello, World!"

AWS

The image aws properties allow pipelines to use private images hosted in an Amazon Elastic Container Registry (AWS ECR). The aws property supports two authentication methods:

  • アクセス キーとシークレット キー (access-keysecret-key) を使用する

  • OpenID Connect (OIDC) ロール (oidc-role) を使用する

For details, see Private images hosted by AWS ECR (EC2 Container Registry).

Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.

プロパティaws

必須 — いいえ

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

Allowed parent propertiesimage

指定可能な子プロパティ — 次のいずれかが必要です。

例 — aws、access-key、secret-key を使用して、AWS ECR から非公開イメージを取得する

image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: access-key: $AWS_ACCESS_KEY secret-key: $AWS_SECRET_KEY pipelines: default: - step: oidc: true script: - echo "Hello, World!"

例 — aws と oidc-role を使用して、AWS ECR から非公開イメージを取得する

image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name> pipelines: default: - step: oidc: true script: - echo "Hello, World!"

Access-key と Secret-key

Amazon Elastic Container Registry (AWS ECR) の非公開イメージを使用する場合は、access-keysecret-key の各オプションを使用する必要があります。

Access-key

The aws access-key property, when used with the secret-key property, provides Bitbucket Pipelines with access to private Docker images hosted in an Amazon Elastic Container Registry (AWS ECR). For details, see Private images hosted by AWS ECR (EC2 Container Registry).

Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.

プロパティaccess-key

必須 — いいえ

データ タイプ — 文字列

Allowed parent propertiesaws

例 — aws、access-key、secret-key を使用して、AWS ECR から非公開イメージを取得する
image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: access-key: $AWS_ACCESS_KEY secret-key: $AWS_SECRET_KEY pipelines: default: - step: script: - echo "Hello, World!"
例 — aws、access-key、secret-key を使用して、単一ステップ用に AWS ECR の非公開イメージを取得する
image: my/bash:lts pipelines: default: - step: image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: access-key: $AWS_ACCESS_KEY secret-key: $AWS_SECRET_KEY script: - echo "Hello, World!"
例 — aws、access-key、secret-key を使用して、AWS ECR の非公開イメージをサービス コンテナーとして使用する
definitions: services: my-service: image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: access-key: $AWS_ACCESS_KEY secret-key: $AWS_SECRET_KEY pipelines: default: - step: services: - my-service script: - echo "Hello, World!"
Secret-key

The aws secret-key property, when used with the access-key property, provides Bitbucket Pipelines with access to private Docker images hosted in an Amazon Elastic Container Registry (AWS ECR). For details, see Private images hosted by AWS ECR (EC2 Container Registry).

Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.

プロパティsecret-key

必須 — いいえ

データ タイプ — 文字列

Allowed parent propertiesaws

例 — aws、secret-key、access-key を使用して、AWS ECR の非公開イメージを取得する
image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: access-key: $AWS_ACCESS_KEY secret-key: $AWS_SECRET_KEY pipelines: default: - step: script: - echo "Hello, World!"
例 — aws、secret-key、access-key を使用して、単一ステップ用に AWS ECR の非公開イメージを取得する
image: my/bash:lts pipelines: default: - step: image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: access-key: $AWS_ACCESS_KEY secret-key: $AWS_SECRET_KEY script: - echo "Hello, World!"
例 — aws、secret-key、access-key を使用して、AWS ECR の非公開イメージをサービス コンテナーとして使用する
definitions: services: my-service: image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: access-key: $AWS_ACCESS_KEY secret-key: $AWS_SECRET_KEY pipelines: default: - step: services: - my-service script: - echo "Hello, World!"

OIDC-roles

The aws oidc-role property provides Bitbucket Pipelines with access to private Docker images hosted in an Amazon Elastic Container Registry (AWS ECR). For details, see Use AWS ECR images in Pipelines with OpenID Connect.

プロパティoidc-role

必須 — いいえ

データ タイプ — 文字列

Allowed parent propertiesaws

例 — aws と oidc-role を使用して、AWS ECR から非公開イメージを取得する
image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name> pipelines: default: - step: oidc: true script: - echo "Hello, World!"
例 — aws と oidc-role を使用して、単一ステップ用に AWS ECR の非公開イメージを取得する
image: my/bash:lts pipelines: default: - step: oidc: true image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name> script: - echo "Hello, World!"
例 — aws と oidc-role を使用して、AWS ECR の非公開イメージをサービス コンテナーとして使用する
definitions: services: my-service: image: name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest aws: oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name> pipelines: default: - step: oidc: true services: - my-service script: - echo "Hello, World!"

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。