All Products
Search
Document Center

Elastic Container Instance:Update the container image of an ECI pod while retaining its IP address

Last Updated:Dec 18, 2025

When iterating on applications deployed as pods on a Virtual Node, you may need to update a container image to fix bugs or add new features. To avoid service disruptions, you often need to retain the pod's IP address during the update. This guide shows how to use kubectl commands to update the container image of an Elastic Container Instance (ECI) pod without changing its IP address.

Prerequisites

You have prepared and pushed the new container image to an image repository.

Procedure

This example updates the container image of an Nginx Pod from nginx:1.7.9 to nginx:1.9.6 while retaining the pod's IP address.

Note

To run this example, ensure that the Virtual Private Cloud (VPC) for your cluster has an Internet NAT gateway and SNAT rules configured. This way, the image can be pulled over the Internet.

  1. Create an ECI pod.

    kubectl create -f nginx.yaml

    The following nginx.yaml file uses the nginx:1.7.9 container image.

    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
      namespace: default
      labels:
        alibabacloud.com/eci: "true" 
    spec:
      containers:
      - image: nginx:1.7.9
        imagePullPolicy: Always
        name: nginx
  2. Query the pod information.

    1. Check the IP address of the pod.

      kubectl get pod/nginx -n default -o wide

      The output shows the pod's IP address is 172.16.22.193.

      NAME    READY   STATUS    RESTARTS   AGE    IP              NODE                           NOMINATED NODE   READINESS GATES
      nginx   1/1     Running   0          5m5s   172.16.22.193   virtual-kubelet-cn-beijing-e   <none>           <none>
    2. Check the pod's image tag.

      kubectl get pod/nginx -n default -o=custom-columns='IMAGE:spec.containers[*].image'

      The output shows the Pod's container image is nginx:1.7.9.

      IMAGE
      nginx:1.7.9
  3. Choose one of the following methods to update the image:

    • kubectl patch

      Run the kubectl patch command to directly update the container image tag.

      kubectl patch pod nginx -p '{"spec":{"containers":[{"name": "nginx","image": "nginx:1.9.6"}]}}'
    • kubectl edit

      Run the kubectl edit command to edit the Pod manifest and update the container image tag.

      kubectl edit pod/nginx -o yaml 
    • kubectl apply

      Open the nginx.yaml configuration file, update the container image tag, and then run the kubectl apply command to apply the change.

      kubectl apply -f nginx.yaml 
  4. Verify the updated pod information.

    1. Check the pod's IP address.

      kubectl get pod/nginx -n default -o wide

      The output confirms the pod's IP address, 172.16.22.193, is unchanged.

      NAME    READY   STATUS    RESTARTS   AGE   IP              NODE                           NOMINATED NODE   READINESS GATES
      nginx   1/1     Running   1          19m   172.16.22.193   virtual-kubelet-cn-beijing-e   <none>           <none>
    2. Check the pod's image tag.

      kubectl get pod/nginx -n default -o=custom-columns='IMAGE:spec.containers[*].image'

      The output shows the container image is now nginx:1.9.6.

      IMAGE
      nginx:1.9.6