Deploy services in separate service clusters

With your service clusters configured, you can now deploy services, routing to them with your new proxy services using the service_cluster label.

  1. Create two example services:

    docker service create --name demoeast \
    --network eastnet \
    --label com.docker.lb.hosts=demo.A \
    --label com.docker.lb.port=8000 \
    --label com.docker.lb.service_cluster=east \
    training/whoami:latest
    
    docker service create --name demowest \
    --network westnet \
    --label com.docker.lb.hosts=demo.B \
    --label com.docker.lb.port=8000 \
    --label com.docker.lb.service_cluster=west \
    training/whoami:latest
    
  2. Ping your whoami service on the mke-node-0 proxy server:

    curl -H "Host: demo.A" http://<mke-node-0 public IP>
    

    The response contains the container ID of the whoami container declared by the demoeast service.

    The same curl command on mke-node-1 fails because that Interlock proxy only routes traffic to services with the service_cluster=west label, which are connected to the westnet Docker network that you listed in the configuration for that service cluster.

  3. Ping your whoami service on the mke-node-1 proxy server:

    curl -H "Host: demo.B" http://<mke-node-1 public IP>
    

    The service routed by Host: demo.B is only reachable through the Interlock proxy mapped to port 80 on mke-node-1.