-
Notifications
You must be signed in to change notification settings - Fork 5
Pushing an image to the Docker Hub
Now that we've created a custom image we might want to make it available for others to use.
In this post we're going to use the Docker Hub which is a online container registry where we can store our container images to make them available to others.
A word of caution with this, we're going to push to a public repository. This means that anyone (and I mean anyone) will be able to pull our image down. So make sure that when you follow this guide, you're not including any sensitive data in your container image.
Ok, let's run through pushing an image to the Docker Hub.
The image we're going to push is the image built in the previous wiki.
Here's the image: -
docker image ls
Ok, we have the image there. Let's jump onto the Docker Hub (create an account if you don't have one) and create a repository: -
Cool. We have the image, we have the remote repository, let's get that image up there!
First thing to do is log into the docker hub: -
docker login
Enter in your username and password and hit enter!
Ok, next thing is to tag the custom image with the repository name: -
docker tag sqlimage1 dbafromthecold/testsqlrepository:testimage
And confirm the image has been tagged: -
docker image ls
So here we're tagging the iamge with the username dbafromthecold, the repository name testsqlrepository, and adding the tag testimage. Notice that the image ID is the same for the original image and the newly tagged one. We haven't created a new image here, we've just tagged the existing image with a new name.
Now that the image is tagged we can push it up to the hub: -
docker push dbafromthecold/testsqlrepository:testimage
Once that's complete, we'll be able to see it on the hub: -
People will now be able to pull our custom image down locally via: -
docker pull dbafromthecold/testsqlrepository:testimage
So that's how to push an image to the Docker Hub so that it's available for others to pull down and run containers from it.