Docker - Hub
Docker - Docker Hub & Public Repositories
Section titled “Docker - Docker Hub & Public Repositories”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.
Using Docker Hub
Section titled “Using Docker Hub”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 loginEnter 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 jenkinsLook 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 imagedocker pull jenkins/jenkins:ltsStep 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 itdocker run -d -p 8080:8080 -p 50000:50000 --name myjenkins jenkins/jenkins:ltsExplanation:
-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.
Pushing Images (Covered in detail later)
Section titled “Pushing Images (Covered in detail later)”To share your own custom images on Docker Hub:
- Build your image locally (
docker build ...). - Tag the image with your Docker Hub username:
docker tag my-local-image:latest yourusername/my-repo-name:tag. - Log in using
docker login. - 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.