[英]How to force docker-compose to download a new image when using docker hub?
I have a docker-compose.yml file which takes the image svka4019/notes2:latest from the docker hub.我有一个 docker-compose.yml 文件,它从 docker hub 获取图像 svka4019/notes2:latest。 However, if I change the image build it and push it, when I run docker-compose it just uses the one it has already downloaded before.
但是,如果我更改镜像构建并推送它,当我运行 docker-compose 时,它只会使用它之前已经下载的镜像。 Here is the docker-compose.yml:
这是 docker-compose.yml:
springboot-docker-compose-app-container:
image: svka4019/notes2:latest
ports:
- "80:5001"
depends_on:
- friendservice
networks:
- mynet
container_name: base_notes
friendservice:
build: ./Pirmas
command: python app.py
ports:
- 5000:5000
container_name: friend
networks:
- mynet
networks:
mynet:
And the command I use for building and running: docker-compose up --build -d
.以及我用于构建和运行的命令:
docker-compose up --build -d
。 For updating the image in docker-hub I use:为了更新 docker-hub 中的图像,我使用:
docker build -t svka4019/notes2
docker push svka4019/notes2
If I use methods as no-cache it just rebuilds friendService container and skips the base one.如果我使用无缓存的方法,它只会重建friendService 容器并跳过基本容器。
As @DazWilkin pointed out in the comments, using latest tag should be used carefully.正如@DazWilkin 在评论中指出的那样,应谨慎使用最新标签。 Not only can it introduce bugs in your app if latest comes with BC breaks, but it also doesn't indicate that a new update must be performed on your machine if you already have an image 'latest'.
如果最新的 BC 中断,它不仅会在您的应用程序中引入错误,而且如果您已经拥有“最新”图像,它也不表示必须在您的计算机上执行新的更新。
In your case, what you have to do should you want to keep using latest, is to simply call:在你的情况下,如果你想继续使用最新的,你必须做的就是简单地调用:
docker-compose pull
In case you are building your own image, then you must do:如果您要构建自己的映像,则必须执行以下操作:
docker-compose build --pull
The latter will tell docker-compose to first pull the base image before building your custom image.后者会告诉 docker-compose 在构建自定义镜像之前先拉取基础镜像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.