How to immediately terminate the Spring Boot Yarn container with an error

Imagine an error or exception occurs while running the Spring Boot Yarn container, and we need to kill container from itself and return an error code.

You can use @OnContainerStart annotation as mentioned in this article:

But if we need to stop the container immediately, we just need to call:


– where parameter is the error code. The container will immediately stop, and the specified error code will be sent to the AppMaster.

P.S. if you receive another error code in AppMaster, read the article carefully:

Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *