varnish / docker-varnish

Official docker image
https://hub.docker.com/_/varnish
82 stars 34 forks source link

How can I update DAEMON_OPTS? #26

Closed robsoned closed 3 years ago

robsoned commented 3 years ago

Hello, I'm trying to update some config, but I cannot find on the documentation anything related of where to find the configuration file on this docker image. To be able to map it and make some changes

Thanks

gquintard commented 3 years ago

Hi,

Does the info here https://hub.docker.com/_/varnish helps?

robsoned commented 3 years ago

@gquintard Hi, thanks for your help. I was looking for the documentation of how to change the opts on the config file, more precisely http_resp_hdr_len. According to some foruns the file is located depending on the Linux distribution.

CentOS 6: /etc/sysconfig/varnish CentOS 7: /etc/varnish/varnish.params Debian: /etc/default/varnish Ubuntu: /etc/default/varnish

In this case, it is Debian. But I cannot find this file under its location. Here is the snippet of my docker-compose file

varnish:
image: varnish:6.0
container_name: varnish
restart: unless-stopped
environment: 
  - VARNISH_SIZE=${VARNISH_SIZE}
volumes: 
  - ./varnish/varnish.vcl:/etc/varnish/default.vcl
ports: 
  - "80:80"

Can you help me to solve this challenge?

Thanks

gquintard commented 3 years ago

Hi,

Sure, that's pretty straightforward, check out https://github.com/varnish/docker-varnish/blob/master/docker-varnish-entrypoint

Basically, if you specify a command that starts with a -, the whole thing is appended to the default command. so in your docker-compose file, you can add

command:
  - p
  - http_resp_hdr_len=17

and that should do the trick. The whole thing with /etc/default/varnish and others is that they are configuration files used by the init system, and docker doesn't use one, so you need to pass the arguments to the varnishd process yourself. Hopefully the entry_point provided makes it easy to add your parameters, or to rewrite the whole command yourself if you want to

robsoned commented 3 years ago

@gquintard Thanks a lot for your help. I managed to set it right with a little change on the command you sent:

command:
  - -p
  - http_resp_hdr_len=${HTTP_RESP_HDR_LEN}

I think it would be nice to have this kind of information in the Documentation as well.

Thanks

gquintard commented 3 years ago

indeed, I'll make a note for it.