To work with container images in a registry using Docker, you add the registry certificate to the Docker client. The certificate is used to authenticate Docker during registry login.

Configure your Docker client to interact with a container registry, such as the Harbor Registry or Docker Hub. This example assumes you are using the Harbor Supervisor Service.

Prerequisites

This task assumes that you are using a Linux host (Ubuntu) on which the Docker daemon is installed. To install the Docker Engine (daemon) on an Ubuntu host, see https://docs.docker.com/engine/install/ubuntu/.

To verify that Docker is installed and that you can pull images from the Docker hub, run the following command:
docker run hello-world
Expected result:
Hello from Docker!
This message shows that your installation appears to be working correctly.
Note: These instructions are verified using Ubuntu 20.04 and Docker 19.03.

Procedure

  1. Log in to Harbor Registry.
  2. Select Administration > Configuration > Registry Root Certificate.
  3. Click Download to download the Harbor Registry certificate named ca.crt.
    Note: If necessary, change the name of the certificate to ca.crt.
  4. Securely copy the ca.crt file to your Docker host client.
  5. On the Docker host, create a directory path for the private registry using the Harbor IP address.
    /etc/docker/certs.d/IP-address-or-FQDN-of-harbor/
    For example:
    mkdir /etc/docker/certs.d/10.179.145.77
  6. Move the ca.crt to this directory.
    For example:
     mv ca.crt /etc/docker/certs.d/10.179.145.77/ca.crt
  7. Restart the Docker daemon.
    sudo systemctl restart docker.service
  8. Log in to the embedded Harbor Registry using your Docker client.
    docker login https://10.179.145.77
    You should see the following message:
    WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.
    Configure a credential helper to remove this warning. See
    https://docs.docker.com/engine/reference/commandline/login/#credentials-store
    
    Login Succeeded