Update docker image in Azure Container Instances
Asked Answered
S

4

32

I have an image in the repository on the docker hub. I created azure container instance based on the image in the repository on the docker hub. I updated the image in the repository on the docker hub. How can I apply changes to a container?

Saddler answered 12/4, 2018 at 12:46 Comment(0)
B
15

The ways I've found so far are

  1. to use the Azure Resource explorer.

    • Find the container group
    • Click read/write
    • Click edit
    • Change the image version
    • Put password in imageRegistryCredentials when using a private registry.
    • Click Post
  2. This blog post using the Go SDK.

  3. Delete and recreate the group by using an ARM template. You'll loose the public ip using this approach.

You'll have some downtime in any of the cases above.

Behlke answered 12/4, 2018 at 14:27 Comment(3)
I don't see the "Click read/write" button. Was it removed?Mannerly
@Taylor I think LoekD means the read/write button on the top nav bar. It's required before any values can be changed, otherwise an error requiring that mode will be shown.Centipede
I might be getting old here, but I still don't see it :|Hepatitis
E
17

If you follow the practice of naming tags :latest then there's no need to re-create the Container

  1. Push the image
  2. Reset the Container Instance
  3. Done!

This is for image only update

Eloquence answered 18/2, 2020 at 7:33 Comment(4)
How do you reset the image? The azure CLI has an az container restart command, but I'm not sure that does the same thing or pulls the latest version of the image.Wist
Having just tested this, it does just require a restart. I have a container deployed which is referencing the :latest tag. Executing the az container restart command resulting in the image being pulled again and deployed.Yetah
This does work. MS docs also states that az container restart will pull in the latest image from your azure container registry. learn.microsoft.com/en-us/cli/azure/…Dylandylana
This method does work, but you can only roll forward. Rolling backwards would mean tagging an older version with :latestZimmer
A
16

You can also use Azure CLI. Run az container create again using the same resource group name and container group name, with the new image tag. The container will be updated with new image.

Atonic answered 19/4, 2018 at 20:19 Comment(4)
Also needed some more params for Windows type containers. See doc'nVerism
What if the tag name doesn't change, ie you're using a branch tag of master or latestWist
this does not seem work @anders. if the container exists, you get this error: "If you are going to update the os type, restart policy, network profile, CPU, memory or GPU resources for a container group, you must delete it first and then create a new one"Radiocarbon
You can make this work, if you do az container export --file. And then use the file to recreate. But secrets are stripped from the export. You can add them manually using yq or something similarZimmer
B
15

The ways I've found so far are

  1. to use the Azure Resource explorer.

    • Find the container group
    • Click read/write
    • Click edit
    • Change the image version
    • Put password in imageRegistryCredentials when using a private registry.
    • Click Post
  2. This blog post using the Go SDK.

  3. Delete and recreate the group by using an ARM template. You'll loose the public ip using this approach.

You'll have some downtime in any of the cases above.

Behlke answered 12/4, 2018 at 14:27 Comment(3)
I don't see the "Click read/write" button. Was it removed?Mannerly
@Taylor I think LoekD means the read/write button on the top nav bar. It's required before any values can be changed, otherwise an error requiring that mode will be shown.Centipede
I might be getting old here, but I still don't see it :|Hepatitis
I
14

In addition to the mentioned re-creation of the container group and depending on your scenario you could also deploy a container group pointing to the :latest docker image once.

In my scenario I have a scheduled container instance that is running once a day. Whenever it starts it is pulling the docker image with the :latest tag from the azure container registry. This avoids re-creation of the container group.

Irmgard answered 4/6, 2019 at 8:39 Comment(1)
Most practical solution, also for continues delivery.Phototherapy

© 2022 - 2024 — McMap. All rights reserved.