Getting Started With Docker Hub

Docker is an open-source platform that packages applications for distribution. It gives you a way to combine applications and their dependencies into containers that run in any environment. Docker Hub is a service for sharing those containers. It’s the largest source of containers in the world. If you’ve run a Docker container or built an image, it relied on a component that originated from Docker Hub.

You can publish your images to Docker Hub too. You can create and use any public repository for free, and you can create and share private repos with a paid account. This post will go over how to get started with Docker Hub.

Docker Hub in Action

Let’s take a look at Docker Hub in action.

$ docker run hello-world

Unable to find image ‘hello-world:latest’ locally

latest: Pulling from library/hello-world

2db29710123e: Pull complete

Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685

Status: Downloaded newer image for hello-world:latest

 

Hello from Docker!

This message shows that your installation appears to be working correctly.

 

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the “hello-world” image from the Docker Hub.

(amd64)

  1. The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading.

  1. The Docker daemon streamed that output to the Docker client, which sent it

to your terminal.

 

To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it ubuntu bash

 

Share images, automate workflows, and more with a free Docker ID:

https://hub.docker.com/

 

For more examples and ideas, visit:
https://docs.docker.com/get-started/

 

Line 2 indicates that my local system didn’t have a copy of the ‘hello-world’ container available. So, on line 3, Docker pulled the image from library/hello-world.

You can see information about this image on Docker Hub here.

Docker’s default behavior, when it can’t find a local copy of an image, is to look on Docker Hub.

You can also store your images there. So you can make your images available to other users too.

Let’s see how.

Getting Started

All you need to start sharing images on Docker Hub is a free account and a repository.

First, create a Docker ID here .

Now you have access to Docker Hub repositories and can look for images from verified publishers and the open-source community.

If you want to share images, you need to create your own repository.

So sign in to Docker Hub with your Docker ID. This will take you to your page.

This user has a few repos already, but you’ll see the same “Create Repository” button. Click it.

Fill out the form and click “Create.” You now have a repository!

Let’s finish up by saving an image to it. First, log in to Docker Hub on your system.

$ docker login

Login with your Docker ID to push and pull images from Docker Hub. If you don’t have a Docker ID, head over to https://hub.docker.com to create one.

Username: ericgoebelbecker

Password:

WARNING! Your password will be stored unencrypted in /home/egoebelbecker/.docker/config.json.

Configure a credential helper to remove this warning. See

https://docs.docker.com/engine/reference/commandline/login/#credentials-store

 

Login Succeeded

 

Then, starting in a new empty directory, create a Dockerfile with your favorite text editor.

from hello-world

 

Now, build your image and push it to your new repo.

$ docker build -t ericgoebelbecker/mynewrepo .

Sending build context to Docker daemon  2.048kB

Step 1/1 : from hello-world

—> feb5d9fea6a5

Successfully built feb5d9fea6a5

Successfully tagged ericgoebelbecker/mynewrepo:latest

$ docker push ericgoebelbecker/mynewrepo

Using default tag: latest

The push refers to repository [docker.io/ericgoebelbecker/mynewrepo]

e07ee1baac5f: Mounted from library/hello-world

latest: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525

 

Head back to the Docker Hub website, and you’ll see your image.

 

Start With Docker Hub Today

Docker Hub is the central repository that makes Docker the tool we know and love. Get started with sharing and finding great images today.

Cprime offers a three-day Docker boot camp for you and your team. Get the skills you need to radically simplify application deployment, power up your IT workflow, and more with the power of Docker containerization.

Docker Containerization Boot Camp

Register Now
Eric Goebelbecker
Eric Goebelbecker
This post was written by Eric Goebelbecker. Eric has worked in the financial markets in New York City for 25 years, developing infrastructure for market data and financial information exchange (FIX) protocol networks. He loves to talk about what makes teams effective (or not so effective!).nd/or redesign their infrastructure for a more Cloud Native approach.