Giter Club home page Giter Club logo

docker-varnish's Introduction

Supported tags and respective Dockerfile links

What is Varnish?

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.

wikipedia.org/wiki/Varnish_(software)

How to use this image.

Basic usage

Create a default.vcl file:

vcl 4.0;

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

Then run:

$ docker run --name my-running-varnish -v /path/to/default.vcl:/usr/local/etc/varnish/default.vcl:ro -d tripviss/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 tripviss/varnish:5.1

COPY default.vcl /usr/local/etc/varnish/

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

$ docker run --name my-running-varnish -d my-varnish

Exposing the port

$ docker run --name my-running-varnish -d -p 8080:6081 my-varnish

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

Advanced configuration using environment variables

You can override the size of the cache:

$ docker run --name my-running-varnish -e "VARNISH_MEMORY=1G" -d my-varnish

You can pass additional parameters to the varnishd process:

$ docker run --name my-running-varnish -e "VARNISH_DAEMON_OPTS=-t 3600 -p http_req_hdr_len=16384 -p http_resp_hdr_len=16384" -d my-varnish

You can change the path of the VCL configuration file:

$ docker run --name my-running-varnish -e "VARNISH_VCL=/root/custom.vcl" -v /path/to/custom.vcl:/root/custom.vcl:ro -d my-varnish

You can also change the ports used in a Dockerfile.

FROM tripviss/varnish:5.1

ENV VARNISH_PORT 8080
ENV VARNISH_DAEMON_OPTS "additional varnish options here"
EXPOSE 8080

Or with a command:

$ docker run --name my-running-varnish -e "VARNISH_PORT=80" -d -p 80:80 my-varnish

How to install VMODs (Varnish Modules)

Varnish Modules are extensions written for Varnish Cache.

To install Varnish Modules, you will need the Varnish source to compile against. This is why we install Varnish from source in this image rather than using a package manager.

Install VMODs in your Varnish project's Dockerfile. For example, the following Dockerfile would install varnish with libvmod-querystring module:

FROM tripviss/varnish:5.1

# libvmod-querystring requires libpcre available by installing libpcre3-dev
RUN apt-get update
RUN apt-get install -y -q --no-install-recommends \
    libpcre3-dev

# Install Querystring Varnish module
ENV QUERYSTRING_VERSION 1.0.2
ENV QUERYSTRING_FILENAME libvmod-querystring-1.0.2.tar.gz
RUN set -xe \
    && curl -fSL "https://github.com/Dridi/libvmod-querystring/releases/download/v$QUERYSTRING_VERSION/vmod-querystring-$QUERYSTRING_VERSION.tar.gz" -o "$QUERYSTRING_FILENAME" \
    && mkdir -p /usr/local/src/libvmod-querystring \
    && tar -xzf "$QUERYSTRING_FILENAME" -C /usr/local/src/libvmod-querystring --strip-components=1 \
    && rm "$QUERYSTRING_FILENAME" \
    && cd /usr/local/src/libvmod-querystring \
    && sed -i s/-Werror/-W/ configure \
    && ./configure --with-rst2man=: \
    && make \
    && make check \
    && make install \
    && rm -r /usr/local/src/libvmod-querystring

COPY default.vcl /usr/local/etc/varnish/
ENV VARNISH_MEMORY 1G
ENV VARNISH_PORT 1900
EXPOSE 1900

License

View license information for the software contained in this image.

Supported Docker versions

This image is supported on Docker version 1.12.3.

Support for older versions (down to 1.6) is provided on a best-effort basis.

Please see the Docker installation documentation for details on how to upgrade your Docker daemon.

User Feedback

Issues

If you have any problems with or questions about this image, please contact us through a GitHub issue.

Contributing

You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.