Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Serverless Containers
  • Comparison with other Yandex Cloud services
    • Overview
    • Container
    • Invoking a container
    • Runtime environment
    • Networking
    • Mounting external resources to a container file system
    • Long-lived containers
    • Container termination notifications
    • Dead Letter Queue
    • Container logs
    • Backups
    • Quotas and limits
  • Access management
  • Pricing policy
  • Terraform reference
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Notifying the Docker image code in an active instance of a long-lived container
  • Notifying the Docker image code in an inactive container instance
  1. Concepts
  2. Container termination notifications

Container termination notifications

Written by
Yandex Cloud
Updated at October 21, 2024
  • Notifying the Docker image code in an active instance of a long-lived container
  • Notifying the Docker image code in an inactive container instance

In some cases, the service may forcibly terminate a container instance. In which case the Docker image code gets a notification of upcoming forced termination.

Depending on the timeout specified in the container revision settings and the current state of the container instance, you can see one of the two notification types:

  • For active instances of long-lived containers
  • For inactive container instances

The most important difference between these types of notifications is the amount of time allowed for a container to complete its operation normally before the instance is forced to terminate. You should keep this difference in mind for listeners of these notification types.

Notifying the Docker image code in an active instance of a long-lived containerNotifying the Docker image code in an active instance of a long-lived container

Note

This feature is in the Preview stage. To get access, contact tech support or your account manager.

This type of notification is sent to the Docker image code if the following conditions are met:

  • The container is a long-lived one.
  • More than ten minutes are left before expiry of the timeout specified in the container revision settings.
  • The container instance is currently active, i.e., it is processing at least one call.

The Docker image code receives a notification about the upcoming forced termination of the container instance ten minutes before the forced termination. The Termination signal — SIGTERM POSIX signal is sent as the notification.

Add to the application code in the Docker image a listener that will respond to the incoming SIGTERM POSIX signal from the operating system. This will allow you to prevent data loss in case of abnormal abort of call processing due to forced termination of the container instance.

If a long-lived container does not have a SIGTERM listener, the OS will close the user app after sending the notification as an app that ignored the termination signal.

You can disable signals about the upcoming forced termination of the container instance. To do this, you need to add the X_YCF_NO_GRACEFUL_SHUTDOWN_SIGNAL environment variable set to 1 to the container revision. In this case, the container instance will also have 10 minutes to complete its operations but the forced termination notice will not be sent to the Docker image code.

Notifying the Docker image code in an inactive container instanceNotifying the Docker image code in an inactive container instance

This type of notification is sent to the Docker image code if the instance is inactive, i.e., it is not processing any calls at the moment.

Upon a decision to forcibly terminate an inactive container instance, the Docker image code will first get the SIGTERM POSIX signal and then (50 milliseconds later) the SIGKILL POSIX signal that will forcibly terminate the process.

Such container instance termination will forcibly terminate all network connections at the L3 level of the OSI network model.

In the application code in the Docker image, you can use a listener to intercept an incoming SIGTERM signal. This will enable you, for example, to normally terminate sessions in your network connections (at the L7 level of the OSI network model).

Note

Once the SIGTERM signal is sent, the Docker image will have not more than 50 milliseconds to complete the required operations.

Notifications to the Docker image code of an inactive container instance are not subject to any conditions. The timeout value specified in the container revision does not apply. You cannot disable such notifications or adjust the wait time.

Was the article helpful?

Previous
Long-lived containers
Next
Overview
© 2025 Direct Cursus Technology L.L.C.