Skip to content

Docker - Hub

Docker Hub is the default and largest cloud-based registry service provided by Docker. It serves as a central place to find, store, and share Docker images.

Key features of Docker Hub:

  • Public Repositories: Host and share your images publicly, making them accessible to anyone.
  • Private Repositories: Store proprietary or sensitive images securely (limited number available on free plans, more on paid plans).
  • Official Images: Curated and maintained images for popular software (like ubuntu, python, node, nginx, mysql) provided by Docker and upstream vendors.
  • Verified Publisher Images: Images provided and verified by trusted software vendors.
  • Community Images: A vast collection of images shared by the Docker community.
  • Automated Builds: Automatically build images from source code repositories (like GitHub or Bitbucket) when changes are pushed.
  • Webhooks: Trigger actions in other services when images are pushed to Docker Hub.
  • Organizations & Teams: Manage access to repositories for groups of users.

Step 1: Sign Up / Log In

You need a Docker ID to push images or use private repositories. Sign up for a free account at https://hub.docker.com/.

To push images from your local machine, you first need to log in using the Docker CLI:

docker login

Enter your Docker ID (username) and password when prompted.

Step 2: Finding Images

You can search for images directly on the Docker Hub website or using the CLI:

# Search for images related to 'jenkins'
docker search jenkins

Look for OFFICIAL or VERIFIED PUBLISHER images for trusted sources. For Jenkins, the official image is typically jenkins/jenkins.

Step 3: Pulling Images

Use docker pull to download images. If you don’t specify a registry host, Docker assumes Docker Hub.

# Pull the Long-Term Support (LTS) version of the official Jenkins image
docker pull jenkins/jenkins:lts

Step 4: Running Images

Use docker run to start a container from the pulled image. Remember to map necessary ports.

# Run Jenkins container in detached mode, mapping ports, and naming it
docker run -d -p 8080:8080 -p 50000:50000 --name myjenkins jenkins/jenkins:lts

Explanation:

  • -d: Run detached (background).
  • -p 8080:8080: Map host port 8080 to container port 8080 (Jenkins web UI).
  • -p 50000:50000: Map host port 50000 to container port 50000 (used for Jenkins agent connections).
  • --name myjenkins: Assign a name to the container.
  • jenkins/jenkins:lts: The image to run.

After running, you can typically access the Jenkins setup wizard at http://localhost:8080.

To share your own custom images on Docker Hub:

  1. Build your image locally (docker build ...).
  2. Tag the image with your Docker Hub username: docker tag my-local-image:latest yourusername/my-repo-name:tag.
  3. Log in using docker login.
  4. Push the tagged image: docker push yourusername/my-repo-name:tag.

Docker Hub is an essential part of the Docker ecosystem for discovering, distributing, and managing container images.