docs/varnish
Docker Library Bot 3abd666390 Run update.sh 2021-03-26 00:10:59 +00:00
..
README-short.txt
README.md Run update.sh 2021-03-26 00:10:59 +00:00
content.md [varnish] add extra configuration explanations 2021-03-24 17:24:46 -07:00
github-repo
license.md
logo.png
maintainer.md

README.md

Quick reference

Supported tags and respective Dockerfile links

Quick reference (cont.)

What is Varnish?

Varnish is an HTTP accelerator designed for content-heavy dynamic web sites as well as APIs. In contrast to other web accelerators, such as Squid, which began life as a client-side cache, or Apache and nginx, which are primarily origin servers, Varnish was designed as an HTTP accelerator. Varnish is focused exclusively on HTTP, unlike other proxy servers that often support FTP, SMTP and other network protocols.

wikipedia.org/wiki/Varnish_(software)

logo

How to use this image.

Basic usage

Create a default.vcl file:

vcl 4.0;

backend default {
  .host = "www.nytimes.com:80";
}

Then run:

# we need both a configuration file at /etc/varnish/default.vcl
# and our workdir to be mounted as tmpfs to avoid disk I/O
$ docker run -v /path/to/default.vcl:/etc/varnish/default.vcl:ro --tmpfs /var/lib/varnish:exec varnish

Alternatively, a simple Dockerfile can be used to generate a new image that includes the necessary default.vcl (which is a much cleaner solution than the bind mount above):

FROM varnish

COPY default.vcl /etc/varnish/

Place this file in the same directory as your default.vcl, run docker build -t my-varnish ., then start your container:

$ docker --tmpfs /var/lib/varnish:exec my-varnish

Additional configuration

By default, the containers will use a cache size of 100MB, which is usually a bit too small, but you can quickly set it through the VARNISH_SIZE environment variable:

$ docker run --tmpfs /var/lib/varnish:exec -e VARNISH_SIZE=2G varnish

Additionally, you can add arguments to docker run affter varnish, if the first one starts with a -, they will be appendend to the default command:

# extend the default keep period
$ docker run --tmpfs /var/lib/varnish:exec -e VARNISH_SIZE=2G varnish -p default_keep=300

If your first argument after varnish doesn't start with -, it will be interpreted as a command to override the default one:

# show the command-line options
$ docker run varnish varnishd -?

# list parameters usable with -p
$ docker run varnish varnishd -x parameter

# run the server with your own parameters (don't forget -F to not daemonize)
$ docker run varnish varnishd -a :8080 -b 127.0.0.1:8181 -t 600 -p feature=+http2

Exposing the port

+$ docker run --name my-running-varnish --tmpfs /var/lib/varnish:exec -d -p 8080:80 my-varnish

Then you can hit http://localhost:8080 or http://host-ip:8080 in your browser.

License

View license information for the software contained in this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

Some additional license information which was able to be auto-detected might be found in the repo-info repository's varnish/ directory.

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.