How to push a docker image that has a tag different from docker hub repository?

Let's say I have an account on docker hub and my username is hub_user.

I create a repository called react-dev on it.

Now on my machine, I have created an image tagged company/react/dev.

I can see it using docker image ls:

REPOSITORY                        TAG           IMAGE ID       CREATED         SIZE
company/react/dev                  latest        f344922a299e   7 minutes ago   368MB

Now I'm stuck at pushig this image into that hub repository.

This command does not work:

docker push company/react/dev

Using default tag: latest The push refers to repository [docker.io/company/react/dev]
f63cd7f19f75: Preparing
e8aee5ec6588: Preparing
48ee8f528027: Preparing
f3abd083ca1f: Preparing
d02e39b7f91a: Preparing
0586d9cce1ac: Waiting
48286fbe1b87: Waiting
f22adfb1c0f3: Waiting
9a5d14f9f550: Waiting
denied: requested access to the resource is denied

What should I do?

Upvotes: 1

Views: 2141

Answers (2)

Dashrath Mundkar
Dashrath Mundkar

Reputation: 9222

Well the tag and push should follow the convention like this while pushing to dockerhub.

dockerhub_username/repo_name:$TAG

so when building/tagging image it should be like this

docker build -t hub_user/react-dev:latest

Then push the same image

docker push hub_user/react-dev:latest

Upvotes: 1

atline
atline

Reputation: 31674

You will have to use hub_user/react-dev when push.

For your scenario, you could use docker tag to create a tag TARGET_IMAGE that refers to SOURCE_IMAGE, see this.

Then, something like next could work:

$ docker tag company/react/dev hub_user/react-dev
$ docker push hub_user/react-dev

Upvotes: 2

Related Questions