Deploy the cache

  1. Run the following command to deploy the cache:

    docker stack deploy --compose-file docker-stack.yml dtr-cache
    
  2. Verify the successful deployment of the cache:

    docker stack ps dtr-cache
    

    Docker should display the dtr-cache stack as running.

  3. Register the cache with MSR.

    You must configure MSR to recognize the cache. Use the POST /api/v0/content_caches API to do this, by way of the MSR interactive API documentation.

    1. Access the MSR web UI.

    2. Select API docs from the top-right menu.

    3. Navigate to POST /api/v0/content_caches and click to expand it.

    1. Type the following into the body field:

      {
      "name": "region-asia",
      "host": "https://<cache-url>:<cache-port>"
      }
      
    2. Click Try it out! to make the API call.

  4. Configure your user account.

    In the MSR web UI, navigate to your Account, click the Settings tab, and edit the Content Cache settings to the newly deployed cache.

    Note

    To set up user accounts for multiple users simultaneously, use the /api/v0/accounts/{username}/settings API endpoint.

    Henceforth, you will be using the cache whenever you pull images.

  5. Test the cache.

    1. Verify that the cache is functioning properly:

      1. Push an image to MSR.

      2. Verify that the cache is configured to your user account.

      3. Delete the image from your local system.

      4. Pull the image from MSR.

    2. Check the logs to verify that the cache is serving your request:

      docker service logs --follow dtr-cache_cache
      

      Issues with TLS authentication are the most common causes of cache misconfiguration, including:

      • MSR not trusting the cache TLS certificates.

      • The cache not trusting MSR TLS certificates.

      • Your machine not trusting MSR or the cache.

      You can use the logs to troubleshoot cache misconfigurations.

  6. Clean up sensitive files, such as private keys for the cache, by running the following command:

    rm -rf certs