An image does not exist locally with the tag: while pushing image to local registry
Asked Answered
D

10

84

I am trying to push an image to a local registry running in minikube but get the below error:

Successfully built ee84225eb459
Successfully tagged user/apiserver:0.0.1

$ docker push localhost:5000/user/apiserver:0.0.1

The push refers to a repository [localhost:5000/user/apiserver]
An image does not exist locally with the tag: localhost:5000/user/apiserver

I have already tried starting minikube with below:

minikube start --vm-driver xhyve --insecure-registry localhost:5000
eval $(minikube docker-env)
Delgadillo answered 31/12, 2017 at 0:16 Comment(2)
For me, the answer was simple but annoying to find I forgot to tag my image with the username also i made it private do not know if thats really neccesary please let me know if thats the case. so other people can learn from it and me :) thnx for this post it was helpful. btw sorry I am a little bit off-topic.Lexy
docker push should really return a a clearer error message, like push of image with tag X failed because no image with tag X was found.Housefly
W
53

You need to tag and push the image. When tagging an image, you can use the image identifier (imageId). It is listed when showing the list of all images with docker images. Syntax and an example (using imageId) for creating a tag are:

docker tag <imageId or imageName> <hostname>:<repository-port>/<image>:<tag>
docker tag af340544ed62 example.com:18444/hello-world:mytag

Once the tag, which can be equivalent to a version, is created successfully, you can confirm its creation with docker images and issue the push with the syntax:

docker push <hostname>:<repository-port>/<image>:<tag>

There is an example for local nexus repository

Whoredom answered 30/10, 2019 at 4:27 Comment(3)
Thank you for actually explaining how to add a tag. The top post does not detail this. Recommend this being the top post.Obtuse
This is the best awnser about how to push image, because without tag you can't and thats the only post that explain how to add tag. Thanks!Sext
This answer should be acceptedGreiner
M
44

I was getting the same error, which OP is referring to, googling the exact phrase brought me here, but, in my case, I was pushing it to the default/public repository (hub.docker.com) instead of the local one. But as it turns out the issue was the same

This was my local image which I created on my disk

[root@ip-172-31-22-195 centos]# docker images
REPOSITORY             TAG       IMAGE ID       CREATED        SIZE
centos                 latest    927311af2297   20 hours ago   193MB

I tagged it like this:

docker tag centos devopskalsym:latest

then confirmed the tag being created:

[root@ip-172-31-22-195 centos]# docker images
REPOSITORY             TAG       IMAGE ID       CREATED        SIZE
devopskalsym           latest    927311af2297   20 hours ago   193MB
centos                 latest    927311af2297   20 hours ago   193MB

Since my repository on docker hub was: devopskalsym/centos7, I tried to push it:

docker push devopskalsym/centos7:latest

and got the error:

[root@ip-172-31-22-195 centos]# docker push devopskalsym/centos7:latest
The push refers to repository [docker.io/devopskalsym/centos7]
An image does not exist locally with the tag: devopskalsym/centos7

so I removed the tag with:

[root@ip-172-31-22-195 centos]# docker rmi devopskalsym
Untagged: devopskalsym:latest

then re-tagged correctly with the format mentioned by @BMitch.

docker tag centos:latest devopskalsym/centos7:latest

the format used is this: docker tag local-image:tagname new-repo:tagname

now it correctly shows the images:

[root@ip-172-31-22-195 centos]# docker images
REPOSITORY             TAG       IMAGE ID       CREATED        SIZE
devopskalsym/centos7   latest    927311af2297   20 hours ago   193MB
centos                 latest    927311af2297   20 hours ago   193MB

then pushed it again:

docker push devopskalsym/centos7:latest

and it worked

[root@ip-172-31-22-195 centos]# docker push devopskalsym/centos7:latest
The push refers to repository [docker.io/devopskalsym/centos7]
b7d51bf3d09e: Pushing [==================================>                ]    132MB/193.3MB

Note: you might need to login with docker login

Morales answered 14/1, 2021 at 7:24 Comment(3)
in summary its 2 commands 1. docker tag <source image_name> <target image_name> 2. docker push reponame:<target image_name> Stanzel
Thank you! I was pulling my hair off :DDuodenal
This is accurate. :)Homophony
L
24
Successfully tagged user/apiserver:0.0.1

docker push localhost:5000/user/apiserver:0.0.1

Image tags need to include the registry name/port for you to push them anywhere other than the default registry (docker hub). So you need to tag your image as localhost:5000/user/apiserver:0.0.1 rather than user/apiserver:0.0.1. Then you'll be able to push to your local registry.

Lucillelucina answered 31/12, 2017 at 0:25 Comment(5)
Successfully built 8c921763a005 Successfully tagged localhost:5000/user/apiserver:0.0.1 docker push localhost:5000/user/apiserver:0.0.1 The push refers to a repository [localhost:5000/user/apiserver] Get localhost:5000/v2: dial tcp 127.0.0.1:5000: getsockopt: connection refusedDelgadillo
Also this is after kubectl port-forward $POD 5000:5000 & where POD is my registry-7f8lq or registry pod which did not help eitherDelgadillo
bash-3.2$ curl -X GET localhost:5000/v2/_catalog Handling connection for 5000 {"repositories":[]}Delgadillo
You'll want to open a separate question for that. This is moving from why can't it find my image to why isn't my port forward working.Lucillelucina
Thanks - was able to get it to work with another local registry deployment and port forwarding - Reference link mtpereira.com/local-development-k8s.htmlDelgadillo
B
13

I had an image

trip-bot                     latest     0c9e8f0367bc   36 minutes ago   955MB

And I was getting error

The push refers to repository [docker.io/ilkhr/trip-bot] An image does not exist locally with the tag: ilkhr/trip-bot

Solved the problem like this

$ docker tag 0c9e8f0367bc ilkhr/trip-bot:trip-bot

After that I did so

$ docker push ilkhr/trip-bot:trip-bot
Brasier answered 19/6, 2021 at 10:11 Comment(4)
The problem is regarding the host of the registry missing, the question asker already tagged with the username. Represented by user. This answer sadly does not add anything of value. Sorry.Cityscape
How do you tag in github actions when automating your builds? How do you get the image id?Gunther
@Gunther https://mcmap.net/q/246388/-how-to-get-image-id-of-docker-in-jenkinsPrestonprestress
@ИльяХоришко Thanks. I figured it out. When you build an image using build -t some_name you can reference it with the name some_name. And even multi-tagging. Allows me to always tag versioned releases with the 'latest' tag.Gunther
C
13
  1. first start with docker login with these commands:-

    docker login
    
  2. then check you image id / tag by this command

    docker images
    
  3. once you get your image id/tag then use this command to push to your dockerhub repository

    docker tag <imageId or tag> <dockerhub id>/<imagename>:<tag>
    

or for general you can use

docker tag <imageId or tag> <hostname>:<repository-port>/<imagename>:<tag>

note replace angle brackets with your specific information

Cords answered 6/11, 2021 at 18:57 Comment(0)
M
1

Like others said, issues are typically due to incorrect tagging.

Here is a working example deploying a docker to DockerHub.

The tag format is <namespace>/<repo_name>:<version>. The namespace is typically stored in the repository secrets. Note that it is convenient to assign a tag when building.

name: Docker Image CI

on:
  push:
    branches: [ "main" ]
    paths: ["Dockerfile",".github/workflows/docker-image.yaml"]

jobs:
  build:
    runs-on: ubuntu-latest
    # Docker Hub tag
    env:
      IMAGE_NAME: jupyter-book-gh
      IMAGE_VERSION: latest
    steps:
    - uses: actions/checkout@v3
    - name: Log in to DockerHub
      env:
        DOCKER_USER: ${{secrets.DOCKER_USER}}
        DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
      run: |
        docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
        echo "${{secrets.DOCKER_USER}}/$IMAGE_NAME:$IMAGE_VERSION"
    - name: Build the Docker image
      run: docker build . --file Dockerfile --tag ${{secrets.DOCKER_USER}}/$IMAGE_NAME:$IMAGE_VERSION
    - name: Push the Docker image
      run: docker push ${{secrets.DOCKER_USER}}/$IMAGE_NAME:$IMAGE_VERSION
Maud answered 27/3, 2023 at 12:59 Comment(0)
C
0

If you are trying to push to docker hub and get this tag error, have in mind that at the moment you build your image, you should state the username of your docker hub account in order to push it right.

So in my case, the correct command was

docker image build -t marcofloriano/hello-docker .

And not

docker image build -t hello-docker .

Chaddie answered 11/1, 2023 at 14:34 Comment(0)
M
0

I got this error when pushing to AWS ECR,

for me i had a typo, the format current now as of 2023 is

docker tag image-id <account-id>.dkr.ecr.<region-code>.amazonaws.com/<repo-name>:<tag>

I accidentally deleted the dkr word, and I was getting the same error.

Ref: https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html

Morrill answered 16/7, 2023 at 20:28 Comment(0)
K
0

In addition to this answer, if you receive this error while pushing to AWS ECR inside of a script, ensure the file line endings are appropriate for your OS (LF for Linux/OSX vs CRLF for Windows). This can be changed in most IDEs. For example, in VSCode by clicking the following tray tool:

enter image description here

Knowitall answered 9/8, 2023 at 18:5 Comment(0)
O
0

I experienced the same problem but I created the tag like proposed. Still, I got that very same error message.

The solution for me was to wait a little before pushing, apparently the local registry needs some 'settling time' to update itself(?)

A sleep 10 between those two commands helped:

docker build . -t <my_tag>
sleep 10
docker push <my_tag>
Obstruct answered 16/11, 2023 at 9:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.