06 - Going cloud - Sharing images on Docker Hub

we'll explore the resources available from the Docker Hub website.
  What's Docker Hub for? 
The site offers two main functions: you can learn about available public repositories and you can manage your own repositories. A repository by the way is a place to efficiently store and manage software packages and to make them easily available to either other members of your software team or to the public who you hope will use them.
 
By clicking on "Browse Repos" at the top of the screen you get to this page which offers links to some of the more popular and official repositories available. And also a search engine to search through the many, many thousands of less known but sometimes very useful repositories that are also available.
 
Clicking on the link to a particular repository will first of all provide you with specific information on how to use your command line on your own computer to pull this particular repository from Docker Hub, but often as in the case of nginx there will also be very useful configuration information, how to create a Dockerfile to build your own image of this repository or how to set up ports and networking within the image.
  Search for repositories via command line 
Besides setting up a Docker Hub account and doing some searching for repositories most of the heavy work associated with Docker will still be done from your command line. As it turns out you can also search from your command line for Docker repositories. So you can type "sudo docker search" let's say Apache. And we'll narrow it down because there are an awful lot of repos using Apache so we'll narrow it down to those built on Ubuntu.
 
We've already chosen from before, let's clear the screen to give us a better idea where we are and lets take a look at our current Dockerfile. We see the second line after the comment that we are basing this image on Ubuntu 14.04 then install Apache 2 the web server, and ano and cURL a couple of other software packages I always like to include. Let's leave less and now let's build our image "sudo docker build -t". The name of the repository that we are going to build towards and that is my account. We're going to call it Apache-B and then we are going to build it from the Dockerfile in the current directory. That's the Dockerfile we just looked at. It's built.
  How to push your own repository to Docker Hub 
Now "sudo docker push". We're going to push this image up to our repository or more specifically my repository assigning it the name we'd like it to appear within the repository. And in the process of pushing the image Docker will list for us each layer of the image that is currently being pushed up. Watching how the Docker program actually uploads your image to the repository is educational. You'll notice I simply pasted the output from a push operation using Docker to this slide to make it easier for us to look at it step-by-step. You'll notice that the total repository was broken down into layers. The first layer which has an ID of 511136EA363C5A was already pushed. In other words, that was the base image of Ubuntu. Therefore, the Docker push program skipped it.
 
There's no reason to upload Ubuntu back to Docker: it's already there and if everybody were to upload that original base image with their repository pushes the site would be a whole lot bigger and a great deal of bandwidth would be wasted pulling it down and pushing it back up, pulling it down and pushing it back up.
 
Similarly the next five or six layers of the repository also are simply reflections of elements that already exist online, whether it's the Apache build that I added or some other change that I made based on something that is basically available on the site itself. There were only four layers that actually were uploaded and in total I think they came to less than a hundred megabytes. That streamlining of the push process saves an enormous amount of time and storage space and allows of course the whole Docker operation to work much more efficiently.
 
Now, going back to the website let's click on our own Docker Hub account. Click on "My Repositories" and you'll see that DBClinton/Apache-B is in fact listed among, in fact it's the only repository I have right now on this particular account.
 
Clicking on it will allow me to edit the description and some other metadata or delete it or make it private. You are allowed one private repository on a free account and of course many more on a paid account. And of course as with the more popular repositories the page for your own repository includes the basic pull information you'll need to allow any others to pull this repository if you'd like them to have it too.

Comments

Popular posts from this blog

Cloud Computing in simple

How to Write an Effective Design Document

Bookmark