Sharing your images

The Docker Hub is a central place used for keeping the Docker images either in a public or private repository.

The Docker Hub provides features, such as a repository for Docker images, user authentications, automated image builds, integration with GitHub or Bitbucket, and managing organizations and groups. The Docker Registry component of the Docker Hub manages the repository.

To work with the Docker Hub, you must register an account using the link at https://hub.docker.com/.You can update the Docker Hub ID, Email Address and Password as shown in the following screenshot:

Sharing your images

After completing the Sign Up process, you need to complete the verification received in an e-mail. After the e-mail verification is completed, you will see something similar to the following screenshot, when you login to the Docker Hub:

Sharing your images

As you can see, I already have a few automated builds configured, we will get to these later on, for now we are going to look at pushing an image from our local Docker host.

First, we need to login to the Docker Hub using the Docker client on the command line, to do this simply use the following command:

docker login

You should be prompted for your Docker Hub username and password:

Sharing your images

Now we are ready to start committing and pushing images to the Docker Hub.

We'll again create an image using the Dockerfile we created earlier in the chapter. So, let's create the Docker image using the Dockerfile in /chapter02/build_07_cmdand push the resulting image to the Docker Hub.

Now we build the image locally using the following command making sure to use your own Docker Hub username in place of mine:

docker image build -t russmckendrick/exampleimage .

Once built, you can check the image is there by using:

docker image ls
Sharing your images

As we are already logged in all we need to do to push the newly create image is run the following command:

docker image push russmckendrick/exampleimage
Sharing your images

Finally, we can verify the availability of the image on the Docker Hub:

Sharing your images

This is where I should probably issue a warning: as you have just experienced it is very easy to publish images to the Docker Hub using the docker image push command; however, it is very easy to accidentally push content you maybe wouldn't want to be publicly available. For example, with a simple COPY or ADD instruction in your Dockerfile it is easy to bake sensitive information such as password credentials, certificates keys and non-publicly available code to a publicly accessible Docker Image repository.

It is this reason why I prefer to share a Dockerfile or docker-compose.yml files with my colleagues using private Git repositories and a good set of instructions . A also, it allows then to check what it is they are going to be running as they are able to review theDockerfile and docker-compose.yml files; in fact, they can make changes and share them with me.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.70.213