https://pulumi.com logo
#general
Title
# general
d

dazzling-sundown-39670

08/22/2023, 5:25 PM
Using the docker provider, how can I make pulumi only destroy and recreate the container if the image is actually updated?
I've tried doing it like this:
Copy code
const registryImage = docker.getRegistryImage(
  {
    name: "meisnate12/plex-meta-manager",
  },
  dockerProviderOpts
);

const image = new docker.RemoteImage(
  name,
  {
    name: "meisnate12/plex-meta-manager",
    pullTriggers: [
      registryImage.then((registryImage) => registryImage.sha256Digest),
    ],
  },
  dockerProviderOpts
);
But it still wants to update the image every
pulumi up
, if I select
details
it shows this:
Copy code
image: "sha256:9bf92ccb981db90633aef0366ba0d4cc3ee9f50d8d9f2b25599f7e84eeb355fc" => "meisnate12/plex-meta-manager"
r

rhythmic-kangaroo-13964

08/23/2023, 2:31 AM
If you are using it in a CI/CD environment, you can use the Git SHA for tagging the image. This way you can ensure that replacement only happens when there is a new image.
d

dazzling-sundown-39670

08/23/2023, 6:37 AM
Hey, thanks! Isn't that what I'm doing in the pullTrigger?
r

rhythmic-kangaroo-13964

08/23/2023, 6:58 AM
I haven't really tried with pull triggers, my current way is tag image with the Git SHA, so your case would be something like
meisnate12/plex-meta-manager:#{GIT_SHA}#
, so in pipeline, if there is no new commit, Git SHA remains the same and it won't cause building of new image and replacement of image for pods in K8s cluster (for my case)
d

dazzling-sundown-39670

08/23/2023, 7:13 AM
Oh, this isn't my image, so I'm not building/tagging it