[英]Docker - What is proper way to rebuild and push updated image to docker cloud?
What I'm currently doing:我目前在做什么:
Dockerfile: Dockerfile:
FROM python:3.5.1
ENV PYTHONUNBUFFERED 1
RUN mkdir /www
WORKDIR /www
ADD deps.txt /www/
RUN pip3 install -r deps.txt
ADD . /www/
RUN chmod 0755 /www/docker-init.sh
Build command:构建命令:
docker build -t my-djnago-app:latest .
Tagging:标记:
docker tag my-djnago-app:latest lolorama/my-djnago-app-img:latest
Pushing:推动:
docker push lolorama/my-djnago-app-img:latest
After following these steps, the repository image still hasn't updated.执行这些步骤后,存储库映像仍未更新。 I keep getting this message - "Layer already exists".
我不断收到此消息 - “图层已存在”。
The push refers to a repository [docker.io/lolorama/my-django-app-img]
fd5aa641b308: Layer already exists
d9c60c6f98e8: Layer already exists
d9d14867f6d7: Layer already exists
64ce166099ca: Layer already exists
73b670e35c69: Layer already exists
5f70bf18a086: Layer already exists
9ea142d097a5: Layer already exists
52f5845b1de0: Layer already exists
e7fadb3ab9d4: Layer already exists
cef72744de05: Layer already exists
591569fa6c34: Layer already exists
998608e2fcd4: Layer already exists
c12ecfd4861d: Layer already exists
What am I doing wrong?我究竟做错了什么?
I found the problem, thanks to @lorenzvth7!感谢@lorenzvth7,我发现了问题!
I've had two images with same tag (which i was pushing to cloud).我有两个带有相同标签的图像(我正在推送到云)。
Solution is:解决办法是:
Inspect your images and find two or more with the same tag:检查您的图像并找到两个或多个具有相同标签的图像:
docker images
Delete them:删除它们:
docker rmi --force 'image id'
Another solution, albeit bruteforce, is to rebuild with the --no-cache flag before pushing again.另一个解决方案,尽管是蛮力,是在再次推送之前使用--no-cache标志重建。
docker rmi --force my-djnago-app:latest
docker build -t my-djnago-app:latest . --no-cache
docker push my-djnago-app:latest
I meet the problem as well( In my web application
), like this:我也遇到了这个问题(
In my web application
),如下所示:
# when I push my contaimer to repo
$ docker push <container>
The push refers to repository [docker.io/xx/getting-started]
fd5aa641b308: Layer already exists
d9c60c6f98e8: Layer already exists
d9d14867f6d7: Layer already exists
64ce166099ca: Layer already exists
73b670e35c69: Layer already exists
5f70bf18a086: Layer already exists
9ea142d097a5: Layer already exists
52f5845b1de0: Layer already exists
I try my Solution, and it's works!我尝试了我的解决方案,它的工作原理!
# force remove image
$ docker rmi --force <image-id>
# tag for image
$ docker tag <image-name> <your-dockerHub-username>/<image-name>
# push image, just done!
$ docker push <your-user-name>/<image-name>
terminal output:终端输出:
# when I push my container to repo
$ docker push <container>
The push refers to repository [docker.io/xx/getting-started]
# it'll push your part of changes
fd5aa641b308: Pushed
d9c60c6f98e8: Pushed
d9d14867f6d7: Layer already exists
64ce166099ca: Layer already exists
73b670e35c69: Layer already exists
5f70bf18a086: Layer already exists
9ea142d097a5: Layer already exists
52f5845b1de0: Layer already exists
Then, open my web appliction
, it's updates the lastest version!然后,打开
my web appliction
,它更新了最新版本!
when you build the docker file, add you docker repository name as well.当您构建 docker 文件时,还要添加 docker 存储库名称。
docker build -t <your-dockerHub-username>/my-djnago-app:latest .
in your scenario,在你的场景中,
docker build -t lolorama/my-djnago-app:latest .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.