Unable to stop container operation timed out
Introduction
When managing OpenVZ containers, you may occasionally encounter a situation where a container fails to stop and the operation times out. This is typically caused by a stale checkpoint process or a leftover lock file preventing the container from shutting down gracefully. The following procedure helps resolve the issue and restore normal container operations.
Prerequisites
- Root or sudo access to the OpenVZ host node.
- OpenVZ utilities (
vzctl) installed. - The Container ID (VEID) of the affected VPS.
- Ensure no critical operations are running inside the container before forcing termination.
Steps to Resolve
- Attempt to stop the container forcefully:
$vzctl stop VEID --fast
Example error:Stopping container ...Unable to stop container: operation timed out - Remove the stale lock file:
$rm -f /vz/lock/VEID.lck - Kill the checkpoint process:
$vzctl chkpnt VEID --kill - Start the container again:
$vzctl start VEID - Verify the container status:
$vzlist
or
$vzctl status VEID
Testing
- Confirm the container starts successfully without timeout errors.
- Verify the container appears in the running container list.
- Log in to the container to ensure services are functioning correctly:
$vzctl enter VEID - Check application and system services inside the container to confirm they are operating as expected.
Conclusion
The timeout issue is commonly caused by stale lock files or checkpoint processes left behind after an incomplete shutdown. Removing the lock file and terminating the checkpoint process allows the container to restart normally. After recovery, verify the container’s status and application services to ensure it is functioning correctly. If the issue occurs repeatedly, investigate host resource utilization and container logs to identify the underlying cause.
