Use context and path-based routing

Estimated reading time: 1 minute

This topic applies to Docker Enterprise.

The Docker Enterprise platform business, including products, customers, and employees, has been acquired by Mirantis, inc., effective 13-November-2019. For more information on the acquisition and how it may affect you and your business, refer to the Docker Enterprise Customer FAQ.

The following example publishes a service using context or path based routing.

First, create an overlay network so that service traffic is isolated and secure:

$> docker network create -d overlay demo

Next, create the initial service:

$> docker service create \
    --name demo \
    --network demo \
    --detach=false \
    --label \
    --label \
    --label \
    --label \
    --env METADATA="demo-context-root" \

Only one path per host

Interlock only supports one path per host per service cluster. When a specific label is applied, it cannot be applied again in the same service cluster.

Interlock detects when the service is available and publishes it. After tasks are running and the proxy service is updated, the application is available via http://demo.local:

$> curl -vs -H "Host: demo.local"
*   Trying
* Connected to ( port 80 (#0)
> GET /app/ HTTP/1.1
> Host: demo.local
> User-Agent: curl/7.54.0
> Accept: */*
< HTTP/1.1 200 OK
< Server: nginx/1.13.6
< Date: Fri, 17 Nov 2017 14:25:17 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< x-request-id: 077d18b67831519defca158e6f009f82
< x-proxy-id: 77c0c37d2c46
< x-server-info: interlock/2.0.0-dev (732c77e7) linux/amd64
< x-upstream-addr:
< x-upstream-response-time: 1510928717.306
routing, proxy