简体   繁体   English

Docker - 重建并将更新的图像推送到 docker 云的正确方法是什么?

[英]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:解决办法是:

  1. Inspect your images and find two or more with the same tag:检查您的图像并找到两个或多个具有相同标签的图像:

     docker images
  2. Delete them:删除它们:

     docker rmi --force 'image id'
  3. Thats it!就是这样! Follow steps from my question above.按照我上面问题中的步骤操作。

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.

相关问题 重建码头图像 - Rebuild docker image CI脚本作业之前如何在推送时重建Docker映像 - How to rebuild docker image on push before CI script jobs Docker:将映像直接推送到Pivotal Cloud Foundry - Docker: Push Image directly to Pivotal Cloud Foundry 使用docker部署版本化应用程序的正确方法是什么? - What is the proper way of deploying versioned applications with docker? 避免不断重建Docker映像 - Avoid contantly rebuild docker image 在 Docker 映像中以非 root 用户身份运行 cronjob 的正确方法是什么? - What is the proper way to run a cronjob as a non-root user in a Docker image? 带有 docker-compose 应用程序的 Google Jib,在将映像重建到 Docker 守护程序后重新启动应用程序的快速方法 - Google Jib with docker-compose application, Fast way to restart application after rebuild image to Docker daemon 无法使用 Jenkins CloudFoundryPlugin 将 docker 映像推送到 Cloud Foundry - Unable to push a docker image to Cloud Foundry using Jenkins CloudFoundryPlugin 哪个云区域的 docker 映像推送时间最快? - Which cloud region could have the fastest time for a docker image push? Docker将映像推送到Hub - Docker push image to Hub
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM