Docker - What is proper way to rebuild and push updated image to docker cloud?

DockerDockerfileDocker ImageDocker Cloud

Docker Problem Overview


What I'm currently doing:

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?

Docker Solutions


Solution 1 - Docker

I found the problem, thanks to @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.

Solution 2 - Docker

Another solution, albeit bruteforce, is to rebuild with the --no-cache flag before pushing again.

docker rmi --force my-djnago-app:latest

docker build -t my-djnago-app:latest . --no-cache

docker push my-djnago-app:latest

Solution 3 - Docker

I meet the problem as well(In my web application), like this:

# 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!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlex TView Question on Stackoverflow
Solution 1 - DockerAlex TView Answer on Stackoverflow
Solution 2 - DockerTimothy PerezView Answer on Stackoverflow
Solution 3 - DockerlideanView Answer on Stackoverflow