varnish-docker icon indicating copy to clipboard operation
varnish-docker copied to clipboard

What if i need to run using docker-compose

Open iskyd opened this issue 9 years ago • 1 comments

Is there a way to run it without specify -i and so run varnish in foreground? This is a problem if you're using docker-compose i suppose. I think that something like that (in start.sh)

exec bash -c "exec varnishd -F -f /etc/varnish/default.vcl -s malloc,100M -a 0.0.0.0:${VARNISH_PORT}"

could work.

iskyd avatar Feb 19 '16 10:02 iskyd

Old issue/question, but here's an answer:

You don't need to change the command if running from Compose. Just have compose start the container:

data:
  image: busybox
  volumes:
    - /opt/docker/varnish/var:/var/lib/varnish
    - /opt/docker/varnish/etc:/etc/varnish
varnish:
  image: yourname/varnish
  volumes_from:
    - data
  ports:
    - "8000:80"
  environment:
    VARNISH_PORT: 80
    VARNISH_BACKEND_IP: 1.2.3.4
    VARNISH_BACKEND_PORT: 80

The included start.sh runs varnish (which goes into the background) and then runs varnishlog as the foreground process. This allows you to get logs from varnish by using docker logs or docker-compose logs (though the latter lacks options for tail and follow and will blast your screen with more data than you can process).

This is not an issue and should be closed.

oskapt avatar Jul 20 '16 14:07 oskapt