manios/varnish
Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy.
1.5K
Dockerfile
links6.3.2
, 6.3
, latest
(6.3.2/Dockerfile)5.2.1
, 5.2
(5.2.1/Dockerfile)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. A high level overview of what Varnish does can be seen in this video. More information: Varnish official page.
To use this container, you will need to provide your custom config.vcl (which is usually the case).
docker run -d \
--name some-varnish \
manios/varnish
To test if the container has started you can issue:
docker logs -f --tail 200 some-varnish
The expected output may look like the following:
/etc/varnish is not empty. We are ok to go.
/etc/varnish/secret file does not exist. Creating a new one.
0+1 records in
0+1 records out
104 bytes copied, 0.000431003 s, 241 kB/s
/etc/varnish/secret successfully created!
varnishd (varnish-6.3.2 revision 6870fd661a2b42c2e8adad838b5d92a71f27dccd)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2019 Varnish Software AS
Debug: Version: varnish-6.3.2 revision 6870fd661a2b42c2e8adad838b5d92a71f27dccd
Debug: Platform: Linux,4.4.0-166-generic,x86_64,-junix,-smalloc,-sdefault,-hcritbit
Debug: Child (20) Started
Info: Child (20) said Child starts
Varnish configuration is stored by default to /etc/varnish/default.vcl
file.
You can either use docker volumes or a custom Dockerfile to override default configuration.
Using volumes:
docker run -d \
--name some-varnish \
-v /hostdir/varnish:/etc/varnish \
-p 6081:6081
manios/varnish:testo
The above command creates a new container which:
--name some-varnish
: it's name is some-varnish
-v /etc/varnish:/etc/varnish \
: It mounts the container /etc/varnish
directory to /hostdir/varnish
host directory and copies the initial configuration if directory does not exist or is empty.-p 6081:6081
: It exposes port 6081.Using a custom Dockerfile:
FROM manios/varnish:latest
COPY myconf.vcl /mydir/myconf.vcl
Then run:
docker build -t myvarnish:6.1 . \
&& docker run -d \
--name some-varnish \
-e VCL_CONFIG=/mydir/myconf.vcl \
-p 6081:6081 \
myvarnish:6.1
You can configure Varnish daemon by overriding the following environmental variables:
/etc/varnish/default.vcl
64m
(64 megabytes)-p default_ttl=3600 -p default_grace=3600
For all available values you can instruct official varnishd
parameters documentation.For example, providing we want to have a container with:
/opt/manios.vcl
docker run -d \ --name some-varnish \ -e VCL_CONFIG=/opt/manios.vcl \ -e CACHE_SIZE=1g \ -e 'VARNISHD_PARAMS=-p default_ttl=86400 -p default_grace=5' \ -p 80:6081 \ manios/varnish
You can display statistics from the running container varnishd
instance using varnishstat
utility command. For all available options you can refer to the official documentation.
docker exec -it some-varnish varnishstat
You can display live logs from the running container varnishd
instance using varnishlog
utility command. For all available options you can refer to the official documentation.
docker exec -it myvarnish varnishlog
docker pull manios/varnish