简体   繁体   English

当 Jenkins 构建时,如何重新启动 Docker 容器?

[英]How can I restart Docker Container when Jenkins do build?

I'm doing Spring boot CI/CD task.我正在执行 Spring 引导 CI/CD 任务。 I use Docker and put Jenkins on it and Jenkins makes my Spring project auto build.我使用 Docker 并将 Jenkins 放在上面,Jenkins 使我的 Spring 项目自动构建。

The Deployment is working well, but there's a problem. Deployment 运行良好,但存在问题。 If I did't restart docker container, the new build did not apply.如果我没有重启 docker 容器,则新构建不适用。 So when I check swagger-ui, there no changes.所以当我检查 swagger-ui 时,没有任何变化。 If I have to restart docker, I can see the changes on swagger-ui如果我必须重新启动 docker,我可以在 swagger-ui 上看到更改

What should I check in this case?在这种情况下我应该检查什么?

enter image description here enter image description here在此输入图片描述 在输入图片描述

enter image description here在此处输入图像描述

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 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.不确定您如何配置 docker 构建,或者您是否使用任何编排工具。 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.您还可以尝试将重启策略添加到您的 docker 构建中。 The default is NO, means it will not automatically restart.默认为NO,表示不会自动重启。 docker run --restart always docker 始终运行--重启

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 docker 容器调用主机? - How can I call host from docker container? 如何在Docker容器中将JAVA_OPTS传递给tomcat? - How can I pass JAVA_OPTS to tomcat in a docker container? 如何在我的机器上的 docker 守护程序和 Jenkins 之间建立连接以执行 docker 命令? - How can i establish connection between docker daemon on my machine and Jenkins to execute docker commands? 如何让 Spring 在 Docker 容器中使用 application.yml 文件? - How do I get Spring to use an application.yml file in a Docker container? 我如何在 docker 容器中使用 spring 引导应用程序获取 keycloak realm 证书 - How I can get keycloak realm certs using spring boot application in docker container 在Docker容器中运行时找不到Eureka服务 - Eureka service can not be found when running in Docker Container 我在 Docker 容器中找不到 postgresql 表 - I can't find postgresql tables in Docker container 你如何在春天改变Docker容器TZ? - How do you change the Docker container TZ in spring? 如何在 Spring 单元测试中重新启动关闭的 EmbeddedKafkaServer? - How do I Restart a shutdown embeddedKafkaServer in a Spring Unit Test? 关闭Spring ApplicationContext时Jenkins构建失败 - Jenkins build fails when closing Spring ApplicationContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM