Prerequisites

  • Windows / Mac / Linux
  • Docker installed
  • Harbor private registry running

Docker Overview

Docker is an open-source containerization platform that allows developers to package applications and their dependencies into lightweight, portable containers.

Core concepts:

  • Image: A read-only template containing the application and its dependencies
  • Container: A running instance of an image
  • Registry: A place to store and distribute images

Installation:

  • Windows: Download Docker Desktop from the official website
  • Mac: Download Docker Desktop for Mac
  • Linux (Ubuntu): sudo apt-get install docker-ce docker-ce-cli containerd.io

Verify installation:

docker --version
docker run hello-world

Harbor Overview

Harbor is an open-source enterprise-grade container image registry developed by VMware China and donated to CNCF.

Key features:

  1. Full image lifecycle management
  2. Security scanning and vulnerability detection with Clair
  3. Role-based access control (RBAC) with LDAP/AD integration
  4. Image replication between multiple Harbor instances
  5. High availability via primary-replica replication
  6. Web UI for easy management

Configuration Steps

1. Log in to Harbor

After Harbor starts, access the Harbor web UI. Note the address (e.g., 172.16.1.77), username, and password.

2. Configure Docker to Trust Harbor

Edit the Docker daemon configuration file (daemon.json):

{
  "insecure-registries": [
    "172.16.1.77"
  ]
}

Save the file and restart Docker.

3. Docker Login to Harbor

docker login 172.16.1.77

Enter your username and password to log in successfully.

Working with Images

1. Pull a Base Image

docker pull nginx

2. Build a Custom Image

Create a Dockerfile:

FROM nginx
MAINTAINER wzk
WORKDIR /usr/share/nginx/html
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]

Build the image with the Harbor registry prefix:

docker build -t 172.16.1.77/alibaba-cloud/nginx .

3. Push Image to Harbor

View current images:

docker images

Push to Harbor:

docker push 172.16.1.77/alibaba-cloud/nginx

This guide covers the complete workflow from setting up Docker and Harbor to pushing custom images to your private registry.