Docker Runner doesn't pull the latest image automatically
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
本記事で説明している手順は、現時点でのものとなります。そのため、一部のお客様で特定の状況下で動作したという報告がありますが、正式にサポートされているわけではなく、お客様の特定のシナリオで動作することを保証するものではありません。
本番環境での実施の前に一通り非本番環境で検証し、成功しなかった場合にはサポートされている代替案にフォール バックしてください。
要約
Docker Runner doesn't download newer versions of the image automatically.
環境
Bamboo build and deployment jobs configured to run inside Docker container using Docker Runner.
診断
When running build or deployment jobs in Docker containers using Docker Runner, if a new version of the image being used is available, it doesn't get downloaded before the jobs run. This can cause jobs to fail if new features have been added to the image and are required for the new workflow to succeed.
原因
Bamboo uses a cached image on the build agent. If Docker finds the tag locally, it won't check the remote registry for an updated version of the same tag.
This is related to the following feature request to change this behavior:
BAM-21047 - Getting issue details... STATUS
ソリューション
回避策 1
Setup a cron job that will periodically pull the image on the remote agents.
回避策 2
Use a versioned tag rather than the latest tag for the image. It would still need to be updated in Bamboo whenever a new version is available, but you could use a Global Variable for that, so you only have to update one place. For example:
Create a Global Variable:
Name: busyboxTag Value: uclibc (this is one of the tags for the Busybox Docker image)
- At the job's Docker tab, set it to use the following image:
busybox:${bamboo.busyboxTag}
- Let's say a newer version of the image was made available, tagged "unstable". All you have to do is update the busyboxTag Global Variable value to unstable, and the next build will download it automatically before running the container:
command 18-May-2022 14:27:56 Substituting variable: ${bamboo.busyboxTag} with unstable
[...]
error 18-May-2022 14:27:57 Unable to find image 'busybox:unstable' locally
error 18-May-2022 14:28:00 unstable: Pulling from library/busybox
error 18-May-2022 14:28:01 5f3b81648a12: Pulling fs layer
error 18-May-2022 14:28:02 5f3b81648a12: Download complete
error 18-May-2022 14:28:02 5f3b81648a12: Pull complete
error 18-May-2022 14:28:02 Digest: sha256:0d1d11dbad88f301fe745cf1b3fca8ee44ff5cf1c1be721f36b22bec592d9966
error 18-May-2022 14:28:02 Status: Downloaded newer image for busybox:unstable
This will automatically apply to all build plans that are set to use that image and variable, so you won't have to edit all of them manually or run the docker pull
on each agent.