Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push a docker image to a private repository

I have a docker image tagged as me/my-image, and I have a private repo on the dockerhub named me-private.
When I push my me/my-image, I end up always hitting the public repo.

What is the exact syntax to specifically push my image to my private repo?

like image 599
Eugene Goldberg Avatar asked Feb 05 '15 16:02

Eugene Goldberg


People also ask

Are Docker images private?

Private and Public Docker RegistriesThe Docker Hub can host our images, but they will be publicly available. In most cases, images contain all the code and configuration needed to run an application. In that case, we can either use a Docker Hub private account or set up a private Docker registry on a machine.


3 Answers

You need to tag your image correctly first with your registryhost:

docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]

Then docker push using that same tag.

docker push NAME[:TAG]

Example:

docker tag 518a41981a6a myRegistry.com/myImage
docker push myRegistry.com/myImage
like image 155
Abdullah Jibaly Avatar answered Oct 04 '22 19:10

Abdullah Jibaly


Just three simple steps:

  1. docker login --username username

    • prompts for password if you omit --password which is recommended as it doesn't store it in your command history
  2. docker tag my-image username/my-repo

  3. docker push username/my-repo

like image 41
Abhishek Dasgupta Avatar answered Oct 01 '22 19:10

Abhishek Dasgupta


If you docker registry is private and self hosted you should do the following :

docker login <REGISTRY_HOST>:<REGISTRY_PORT>
docker tag <IMAGE_ID> <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>

Example :

docker login repo.company.com:3456
docker tag 19fcc4aa71ba repo.company.com:3456/myapp:0.1
docker push repo.company.com:3456/myapp:0.1
like image 96
Nicolas Delaforge Avatar answered Oct 04 '22 19:10

Nicolas Delaforge