简体   繁体   English

在基于Docker的映像更新后,Docker不会在compose中更新服务的容器

[英]Docker isn't updating the container of a service in compose after image it's based on was updated

I have a baseimage with some app stuff I rarely update. 我有一个基本映像,其中包含一些我很少更新的应用程序内容。 Then I have an image which is more often updated that uses that baseimage (with FROM in the Dockerfile). 然后我有一个使用该基本映像(在Dockerfile中带有FROM )的映像,该映像更经常更新。 Finally I have a docker-compose on a production server which composes several services by using the app image url (url to a self hosted registry). 最后,我在生产服务器上使用了docker-compose,该服务器通过使用应用程序图片网址(指向自托管注册表的网址)组成了多种服务。 The services have different env variables and commands. 这些服务具有不同的环境变量和命令。

When I need to update a service on production, I only build the app image (not the baseimage). 当我需要在生产环境中更新服务时,我仅构建应用程序映像(而不是基本映像)。 After that, I push the new image to the registry and tag it twice, once with a timestamp and once with 'latest'. 之后,我将新映像推送到注册表并对其进行两次标记,一次使用时间戳,一次使用“最新”。

Then I go into the production server and docker-compose pull the image and finally I docker-compose up -d . 然后我进入生产服务器,并docker-compose pull映像,最后我docker-compose up -d

My expectation is that the image of the service is updated, but when I exec -it <id> bash into the service I don't see the files updated like they should. 我的期望是服务的映像已更新,但是当我在服务中exec -it <id> bash ,我看不到文件应有的更新。

The new image is definitely pulled though, because when I run -it <id> bash into the image I see the updated files. 不过,肯定会拉出新映像,因为当我在映像中run -it <id> bash ,会看到更新的文件。

Start the stack using docker-compose up --build -d otherwise if the projectname_service image already exists it will just run it and not rebuild the layers it needs to. 使用docker-compose up --build -d启动堆栈,否则,如果projectname_service映像已经存在,它将直接运行它,而不重建其需要的层。 And if the base image is updated it should have a new tag that you should update your FROM statement at the top to trigger a full rebuild of the image 如果基础映像已更新,则应具有一个新标记,您应该在顶部更新FROM语句以触发映像的完全重建

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM