Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. Varnish Cache is really, really fast. It typically speeds up delivery with a factor of 300 - 1000x, depending on your architecture.
Starting a Varnish instance is simple:
$ docker run --name some-varnish -d steveeasley/varnish:tag
where some-varnish
is the name you want to assign to your container and tag
is the tag specifying the Version version you want. See the list above for relevant tags.
The easiest way to use your own configuration file is to create your own Docker image based on this image. For example, create a new directory called varnish
and inside it add the following to a file called Dockerfile
:
FROM steveeasley/varnish:4.0
COPY default.vcl /etc/varnish
then cd to that directory and run:
$ docker build --name my-varnish .
$ docker run --name some-varnish -d my-varnish
Watch request log:
$ docker exec -it some-varnish varnishlog
Show backend health:
$ docker exec -it some-varnish varnishadm backend.list