I have a docker images 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?
There are two options:
Go into the hub, and create the repository first, and mark it as private. Then when you push to that repo, it will be private. This is the most common approach.
log into your docker hub account, and go to your global settings. There is a setting that allows you to set what your default visability is for the repositories that you push. By default it is set to public, but if you change it to private, all of your repositories that you push will be marked as private by default. It is important to note that you will need to have enough private repos available on your account, or else the repo will be locked until you upgrade your plan.
Create repository on dockerhub :
$docker tag IMAGE_ID UsernameOnDockerhub/repoNameOnDockerhub:latest
$docker push UsernameOnDockerhub/repoNameOnDockerhub:latest
Note : here "repoNameOnDockerhub" : repository with the name you are mentioning has to be present on dockerhub
"latest" : is just tag
First login your private repository.
eg:
And then tag your image for your private repository
eg:
Finally push your taged images to your private repository
eg:
Reference
Ref: dock.docker.com
This topic provides basic information about deploying and configuring a registry
Run a local registry
Before you can deploy a registry, you need to install Docker on the host.
Use a command like the following to start the registry container:
start_registry.sh
Copy an image from Docker Hub to your registry
Pull the
ubuntu:16.04
image from Docker Hub.Tag the image as
localhost:5000/my-ubuntu
. This creates an additional tag for the existing image. When the first part of the tag is a hostname and port, Docker interprets this as the location of a registry, when pushing.Push the image to the local registry running at
localhost:5000
:Remove the locally-cached images. This does not remove the
localhost:5000/my-ubuntu
image from your registry.Pull the
localhost:5000/my-ubuntu
image from your local registry.According to docs.docker.com, this is very insecure and is not recommended.
Edit the
daemon.json
file, whose default location is/etc/docker/daemon.json
on Linux orC:\ProgramData\docker\config\daemon.json
on Windows Server. If you useDocker for Mac
orDocker for Windows
, clickDocker icon -> Preferences -> Daemon
, add in theinsecure registry
.If the
daemon.json
file does not exist, create it. Assuming there are no other settings in the file, it should have the following contents:With insecure registries enabled, Docker goes through the following steps:
Restart Docker for the changes to take effect.
Simple working solution:
Go here
https://hub.docker.com/
to create a PRIVATE repository with name for examplejohnsmith/private-repository
this is theNAME/REPOSITORY
you will use for your image when building the image.First,
docker login
Second, I use "
docker build -t johnsmith/private-repository:01 .
" (where 01 is my version name) to create image, and I use "docker images
" to confirm the image created such as in this yellow box below: (sorry I can not paste the table format but the text string only)docker push johnsmith/private-repository:01
(Your private repo will be here example https://hub.docker.com/r/johnsmith/private-repository/)Done!
You need to tag your image correctly first with your
registryhost
:Then docker push using that same tag.
Example: