├── start.sh ├── Dockerfile └── README.md /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | exec bash -c \ 6 | "exec varnishd -F -u varnish \ 7 | -f $VCL_CONFIG \ 8 | -s malloc,$CACHE_SIZE \ 9 | $VARNISHD_PARAMS" 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7 2 | MAINTAINER Przemyslaw Ozgo linux@ozgo.info, Marcin Ryzycki marcin@m12.io 3 | 4 | RUN yum update -y && \ 5 | yum install -y epel-release && \ 6 | yum install -y varnish && \ 7 | yum install -y libmhash-devel && \ 8 | yum clean all 9 | 10 | ADD start.sh /start.sh 11 | 12 | ENV VCL_CONFIG /etc/varnish/default.vcl 13 | ENV CACHE_SIZE 64m 14 | ENV VARNISHD_PARAMS -p default_ttl=3600 -p default_grace=3600 15 | 16 | CMD /start.sh 17 | EXPOSE 80 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Varnish Docker container 2 | 3 | > Centos 7 4 | > Varnish 4.x 5 | 6 | ## Usage 7 | 8 | To use this container, you will need to provide your custom config.vcl (which is usually the case). 9 | 10 | ``` 11 | docker run -d \ 12 | --link web-app:backend-host \ 13 | --volumes-from web-app \ 14 | --env 'VCL_CONFIG=/data/path/to/varnish.vcl' \ 15 | million12/varnish 16 | ``` 17 | 18 | In the above example we assume that: 19 | * You have your application running inside `web-app` container and web server there is running on port 80 (although you don't need to expose that port, as we use --link and varnish will connect directly to it) 20 | * `web-app` container has `/data` volume with `varnish.vcl` somewhere there 21 | * `web-app` is aliased inside varnish container as `backend-host` 22 | * Your `varnish.vcl` should contain at least backend definition like this: 23 | ``` 24 | backend default { 25 | .host = "backend-host"; 26 | .port = "80"; 27 | } 28 | ``` 29 | 30 | ## Environmental variables 31 | 32 | You can configure Varnish daemon by following env variables: 33 | 34 | > **VCL_CONFIG** `/etc/varnish/default.vcl` 35 | > **CACHE_SIZE** `64m` 36 | > **VARNISHD_PARAMS** `-p default_ttl=3600 -p default_grace=3600` 37 | 38 | 39 | ## Author(s) 40 | 41 | * Marcin Ryzycki () 42 | * Przemyslaw Ozgo () 43 | 44 | --- 45 | 46 | **Sponsored by** [Typostrap.io - the new prototyping tool](http://typostrap.io/) for building highly-interactive prototypes of your website or web app. Built on top of TYPO3 Neos CMS and Zurb Foundation framework. 47 | --------------------------------------------------------------------------------