Configuration of services: best practice

Hello everyone,
I’m trying to switch with Rancher from a local deployment on a laptop with docker-compose to a swarm/cattle managed by Rancher. Rancher looks pretty cool and I’m also able to trigger containers with the API via Python, cool!

I’m starting now to dig the services and stacks concepts in swarm and I’ve now realised some doubts. I thought to share my steps so that maybe someone could help:

  • I need to apply some file configuration to my services. Easy bind mount on docker-compose, while on a swarm it would require to have some storage/nfs shared across all nodes.
  • Because of the previous point I started looking into docker configs but after some tests it seems that it doesn’t take care of replicating the files across the nodes
  • Since previous point I am thinking again about the storage. I’m looking into convey.

Could anyone share with me what are the best practices for configuration files in services?
Am I going into the right direction?

Thanks!

So it seems like you need to bake your config file into your container. Then you can write a script that populates it based on environment variables from your compose. That seems to be the Docker way. In Rancher, I noticed that it seems like passing files is a no go. Look at the Grafana container: you have to pass the name of a plugin to install rather than the plugin itself. After a bit of searching, here’s a blog post that kind of details some trials and tribulations of Rancher and how to deal with passing files to containers: http://www.it20.info/2017/01/vmware-harbor-as-a-rancher-catalog-entry/

Thanks for the reply! I was kind of afraid about that.
Now what this means (for me at least) is that every docker image for a service that needs a configuration file which is not prepared by the maintainers directly has be hacked like you said…
The perfect example for this is nginx where you need to produce some configuration dynamically (e.g. proxy pass to a certain list of containers based on url) with some variables to be filled per host/project basis.

Maybe I have to go back to an older idea I had. Since I’m a Python programmer I could write a standalone python binary that can be used to convert variables into files template (thank you Jinja2!) who are embedded inside the container image. Those images should be in a catalog (e.g. under the same) where everyone can contribute and where I can at least deposit the ones I need.

If someone else there with another view about the config files in swarm/rancher please share your opinion :slight_smile:

If you’re trying to set up a reverse proxy, maybe try Traefik. It works really well with Rancher and you don’t have to set up a config file.