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?
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.
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
Just three simple steps:
docker login --username username
--password
which is recommended as it doesn't store it in your command historydocker tag my-image username/my-repo
docker push username/my-repo
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With