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 イメージを自社ホスト ランナーで使用する

自社ホスト ランナーを使用する際には、独自のレジストリからアトラシアンの公開 Docker イメージをプルすることも、公開 Docker イメージの修正版を使用することもできます。

自社ホスト ランナーでカスタム Docker レジストリの Docker イメージを使用するには、PAUSE_IMAGEAUTH_PROXY_IMAGE、および CLONE_IMAGE を使用して設定します。

docker container run -it -v /tmp:/tmp \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/docker/containers:/var/lib/docker/containers:ro \ -e ACCOUNT_UUID=<my-account-id> \ -e REPOSITORY_UUID=<my-repository-id> \ -e RUNNER_UUID=<my-runner-id> \ -e OAUTH_CLIENT_ID=<my-oauthclient-id> \ -e OAUTH_CLIENT_SECRET=<my-oauthclient-secret> \ -e WORKING_DIRECTORY=/tmp \ -e RUNTIME_PREREQUISITES_ENABLED=true \ -e PAUSE_IMAGE="my-private-registry/my-pause:latest" \ -e AUTH_PROXY_IMAGE="my-private-registry/my-auth-proxy:latest" \ -e CLONE_IMAGE="my-private-registry/my-clone:latest" \ --name my-runner-b0ae87b8-423b-5c24-9a95-84ddad9cdfae \ docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner

自社ホスト ランナーが使用するアトラシアンの初期設定の Docker イメージは次のとおりです。

  • PAUSE_IMAGEdocker-hub.packages.atlassian.com/google/pause:latest

  • AUTH_PROXY_IMAGEdocker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-auth-proxy:prod-stable

  • CLONE_IMAGEdocker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-dvcs-tools:prod-stable

上記の既定のイメージはすべて、ログインせずに docker pull によって取得できます (これらは公開イメージです)。

If your server is behind a firewall, don’t forget to allowlist the domains you’d like to pull images from.

非公開 Docker レジストリのイメージを使用する

Docker ベースのランナーは、ユーザー名とパスワードを使用して認証できる非公開 Docker レジストリからアトラシアンの公開 Docker イメージをプルするように設定できます。

To use a private Docker image hosted on a Docker registry (such as Docker Hub), create or update the .docker/config.json file with login credentials for the Docker registry. The use of authentication credentials other than basic authentication (a username with a password), such as tokens and timed passwords is not supported. The use of a credential store is also not supported.

.docker/config.json ファイルは次のいずれかの方法で作成できます。

Docker の login コマンドを使用する

ログイン認証情報を使用して ~/.docker/config.json ファイルを作成または更新するには、次の手順に従います。

  1. ランナーのホストで、次のコマンドを実行し、プロンプトが表示されたらユーザー名とパスワードを入力します。

    docker login <registry_hostname>
    • ログインに成功すると、パスワードが非暗号化状態で保存されることを示す警告と「Login Succeeded」というメッセージが表示されます。

    • If you don't receive the warning, the docker instance on the host may be configured to use a credential store, which is not supported.

  2. 次に示すように、ボリューム フラグ (-v) を使用して、ホストの .docker/config.json ファイルをランナー コンテナーにマウントします。

    -v <path_to_docker_config_directory>/.docker:/root/.docker

    <path_to_docker_config_directory>/.docker の既定の場所は ~/.docker/ です。

    例:

    docker container run \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/docker/containers:/var/lib/docker/containers:ro \ -v <path_to_docker_config_directory>/.docker/config.json:/root/.docker/config.json \ -e ACCOUNT_UUID=<my-account-id> \ -e REPOSITORY_UUID=<my-repository-id> \ -e RUNNER_UUID=<my-runner-id> \ -e OAUTH_CLIENT_ID=<my-oauthclient-id> \ -e OAUTH_CLIENT_SECRET=<my-oauthclient-secret> \ -e WORKING_DIRECTORY=/tmp \ -e RUNTIME_PREREQUISITES_ENABLED=true \ -e PAUSE_IMAGE="my-private-registry/my-pause:latest" \ -e AUTH_PROXY_IMAGE="my-private-registry/my-auth-proxy:latest" \ -e CLONE_IMAGE="my-private-registry/my-clone:latest" \ --name my-runner-b0ae87b8-423b-5c24-9a95-84ddad9cdfae \ docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner

Docker の config.json ファイルを手動で作成する

ログイン認証情報を使用して ~/.docker/config.json ファイルを手動で作成または更新するには、次の手順に従います。

  1. ランナーのホストで、プレーン テキスト エディターを使用して、ユーザーのホーム ディレクトリに .docker/config.json ファイルを作成するか、既存の該当ファイルを開きます。

  2. 次に示すように、auths という最上位プロパティを追加します。

    { "auths": { "my-private-registry-uri": { "auth": "dXNlcjpwYXNzd29yZA==" }, "my-other-private-registry-uri": { "auth": "dXNlcjE6cGFzc3dvcmQx" } } }

    Where my-private-registry-uri and my-other-private-registry-uri are the URLs of two private registries, such as Docker Hub. The auth values are the username and password for registries (colon-separated) after they have been base64 encoded. To base64 encode the username and password on a macOS or Linux command line, run:

    echo -n 'user:password' | base64

     

  3. 次に示すように、ボリューム フラグ (-v) を使用して、ホストの .docker/config.json ファイルをランナー コンテナーにマウントします。

    -v <path_to_docker_config_directory>/.docker:/root/.docker

    <path_to_docker_config_directory>/.docker の既定の場所は ~/.docker/ です。

    例:

    docker container run \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/docker/containers:/var/lib/docker/containers:ro \ -v <path_to_docker_config_directory>/.docker/config.json:/root/.docker/config.json \ -e ACCOUNT_UUID=<my-account-id> \ -e REPOSITORY_UUID=<my-repository-id> \ -e RUNNER_UUID=<my-runner-id> \ -e OAUTH_CLIENT_ID=<my-oauthclient-id> \ -e OAUTH_CLIENT_SECRET=<my-oauthclient-secret> \ -e WORKING_DIRECTORY=/tmp \ -e RUNTIME_PREREQUISITES_ENABLED=true \ -e PAUSE_IMAGE="my-private-registry/my-pause:latest" \ -e AUTH_PROXY_IMAGE="my-private-registry/my-auth-proxy:latest" \ -e CLONE_IMAGE="my-private-registry/my-clone:latest" \ --name my-runner-b0ae87b8-423b-5c24-9a95-84ddad9cdfae \ docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner

制限事項

この機能には次の制限があります。

  • Authentication using a credential store is not supported. Only login using basic authentication (username and password) is supported.

  • イメージはレジストリでホストされている必要があります。ランナーでは、常にリモート ホストからイメージがプルされ、ホスト デバイス上のイメージは使用できません。

  • この機能は Docker 自社ホスト ランナーでのみ利用できます。他のランナー (シェルベースのランナーなど) ではコンテナーは使用されません。

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

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