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 イメージをビルドしてコンテナ レジストリへプッシュする

多くの CI および CD ワークフローで、自動テストに合格したアプリケーションを Docker イメージとしてパッケージ化およびデプロイする場合があります。

Docker イメージをビルドする

Docker イメージをビルドする前に、bitbucket-pipelines.yml ファイルに docker: true オプションを追加して、Docker デーモンへのアクセスを有効化する必要があります。

docker: true is a global option that will be applied to all steps. Refer to the Global options help document for more information on the global docker option.

Node.js アプリケーションを Docker ファイルとしてビルドする方法の例を以下に示します。次のプレースホルダーを独自の情報に置き換える必要があります。

  • <my.container.registry.io>

  • <my_app>

  • <my_tag>

bitbucket-pipelines.yml

image: node:10.15.0 pipelines: default: - step: script: - npm install - npm test - docker build -t <my.container.registry.io>/<my_app>:<my_tag> . services: - docker: true

コンテナ リポジトリにプッシュする

アプリケーションを Docker イメージにビルドしたら、安全に保存してデプロイメントに備えるために、コンテナ リポジトリにプッシュすることができます。

プッシュを実行する前に、コンテナ レジストリにログインする必要があります。Docker イメージをコンテナ リポジトリにビルド/プッシュする例を以下に示します。

First make sure you've set up the variables DOCKER_HUB_USER and DOCKER_HUB_PASSWORD, for example.

次に、次のプレースホルダーを独自の情報に置き換える必要があります。

  • <my.container.registry.io>

  • <my_app>

  • <my_tag>

bitbucket-pipelines.yml

image: node:10.15.0 pipelines: default: - step: script: - npm install - npm test  - docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWORD - docker build -t <my.container.registry.io>/<my_app>:<my_tag> . - docker push <my.container.registry.io>/<my_app>:<my_tag> services: - docker

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

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