B.2 Create a Registry

Because a swarm consists of multiple Docker Engines, a registry is required to distribute images to all of them.

  1. Run the following command to start the registry as a service on your swarm.
    docker service create --name registry --publish published=5000,target=5000 registry:2
  2. Run the following command to check the status of the registry.
    docker service ls

    In the response, look for 1/1 under REPLICAS, which indicates that the registry is running. If the response is 0/1, it is probably still pulling the image. Check the status again after some time.

    
    ID             NAME              MODE         REPLICAS   IMAGE            PORTS
    tjc0u55yavu4   registry          replicated   1/1        registry:2       *:5000->5000/tcp
  3. Verify that you can use cURL to access the registry.
    curl http://localhost:5000/v2/