Docker implementation of Varnish
| Name | Description | Default value |
|---|---|---|
| BACKEND_GRACE | VCL Grace | 2h |
| CACHE_MAX_AGE | Cache max age | 10 |
| CACHE_SIZE | Cache size | 64M |
| CACHE_TTL | Cache TTL | 10s |
| OFFLOAD_TO_HOST | Host of backend application | localhost |
| OFFLOAD_TO_PORT | Port of backend application | 5000 |
| VARNISH_HEALTH_CHECK_PATH | Varnish health check path | /healthz |
| VARNISH_PORT | Varnish port to use | 80 |
| VARNISH_PARAMS | Command line configuration |
You can customize the VCL configuration and mount it as follow:
docker run -t -i \
-p 80:80 \
-v "$(pwd)/default.vcl:/etc/varnish/default.vcl" \
varnish
# Run NGINX as backend
docker run -d --name=nginx-alpine nginx:alpine
# Run Varnish
docker run -t -i -p 8080:80 \
-e "OFFLOAD_TO_HOST=nginx-alpine" \
-e "OFFLOAD_TO_PORT=80" \
--link=nginx-alpine \
varnish
# Curl
curl http://localhost:8080 -I
# Response:
# >> HTTP/1.1 404 Not Found
# >> Date: Mon, 21 Nov 2016 13:45:35 GMT
# >> Content-Type: text/html
# >> Content-Length: 169
# >> Age: 0
# >> X-Cache: MISS
# >> X-Cache-Hits: 0
# >> Connection: keep-alive
MIT © Travix International
Content type
Image
Digest
Size
33.2 MB
Last updated
almost 10 years ago
docker pull travix/varnish