Help Center/ Cloud Container Engine/ FAQs/ Workload/ Container Configuration/ When Would a Container Need to Be Rebuilt?
Updated on 2025-04-02 GMT+08:00

When Would a Container Need to Be Rebuilt?

Question

When would a container need to be rebuilt?

Possible Causes

Container rebuilding refers to the process of destroying an existing container and creating a new one. There are various reasons that can trigger container rebuilding. The table below illustrates some common scenarios.

Table 1 Typical scenarios

Scenario

Description

A container crashes or terminates abnormally.

If a running container encounters software errors, resource exhaustion, or other exceptions, the system will automatically rebuild the container to quickly restore services and ensure uninterrupted service.

A container is manually deleted.

If a running container is deleted manually, the container orchestration tool will automatically reschedule and rebuild the container based on the defined deployment policy, ensuring the desired number of pods is maintained.

There is a priority-based preemption.

When a high-priority pod needs resources, Kubernetes may remove a low-priority pod, which will then be rescheduled and started again.

The configuration is updated.

If the configuration (such as the image version, environment variables, and data storage) of a Deployment or StatefulSet is updated, rolling update will be triggered. As a result, the existing container is gradually destroyed and a new one will be created.

Node resources on are insufficient.

When the resources on a node, such as memory and CPUs, are not enough, the cluster may remove certain pods and schedule them on other nodes that have enough resources. This action will then trigger the rebuilding of the containers.

The node is restarted or faulty.

If a node is restarted for any reason, the containers on that node may be destroyed and rebuilt on other available nodes. Similarly, if a node in the cluster is found to be faulty, the cluster will recognize that the node is unavailable and proceed to rebuild the containers on other available nodes.

Using storage (such as EVS disks and file systems) can effectively prevent data loss caused by rebuilding of a container. This ensures that important data is persistently stored and can be used after the container is rebuilt.