Docker images have a tag named latest which doesn’t work as you expect.
Latest is just a tag with a special name.
“Latest” simply means “the last build/tag that ran without a specific tag/version specified”.
Just version your tags. Every time.
docker image有一个tag叫做latest,latest通过最近一次没有指定版本的build或tag来生成
下面实验来看:
$ docker tag imagename localhost:5000/imagename
$ docker push localhost:5000/imagename
这样可以在repository上创建一个版本为latest的imagename,下一次更新操作如下:
1)先停止使用旧的image的container并删除,然后删除旧的image
$ docker stop $container_id
$ docker rm $container_id
$ docker rmi localhost:5000/imagename
2)同上
$ docker tag imagename localhost:5000/imagename
$ docker push localhost:5000/imagename
这种方式不会保留历史版本;
更好的做法是:
1)版本1
$ docker tag imagename localhost:5000/imagename:1
$ docker push localhost:5000/imagename:1
$ docker tag imagename localhost:5000/imagename
$ docker push localhost:5000/imagename
这时latest=1
2)版本2
$ docker tag imagename localhost:5000/imagename:2
$ docker push localhost:5000/imagename:2$ docker stop $container_id
$ docker rm $container_id
$ docker rmi localhost:5000/imagename
$ docker tag imagename localhost:5000/imagename
$ docker push localhost:5000/imagename
这时latest=2
参考:
https://medium.com/@mccode/the-misunderstood-docker-tag-latest-af3babfd6375
https://stackoverflow.com/questions/39352186/update-a-docker-image-in-registry