'How can I restart Docker Container when Jenkins do build?

I'm doing Spring boot CI/CD task. I use Docker and put Jenkins on it and Jenkins makes my Spring project auto build.

The Deployment is working well, but there's a problem. If I did't restart docker container, the new build did not apply. So when I check swagger-ui, there no changes. If I have to restart docker, I can see the changes on swagger-ui

What should I check in this case?

enter image description here enter image description here

enter image description here



Solution 1:[1]

Unless you restart the container , it will be using the same image .

you can refer here

https://serverfault.com/questions/745244/does-docker-restart-use-the-latest-image-or-the-one-the-container-was-created-wi

Not sure how you are configuring the docker build, or are you using any orchestration tools . Please try to add configuration you are using to have more clarity to the question.

Make sure you have a force-pull turned on in the configuration if you are not changing the image tags with each builds

you can also try to add restart-policies to your docker build . The default is NO , means it will not automatically restart. docker run --restart always

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vineesh Vijayan