Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: how to manage development and production settings?

I'm just getting started with Docker. With the official NGINX image on my OSX development machine (with Docker Machine as the Docker host) I ran up against the bug with sendfile and VirtualBox which means the server fails to show changes I make to files.

The workaround for this is to use a modified nginx.conf file that turns off sendfile. This guy's solution has an instruction in the Dockerfile to copy a customised conf file into the container. Alternatively, this guy maps the NGINX configuration to a new folder with modified conf file.

This kind of thing works OK locally. But what if I don't need this modification on my cloud host? How should I handle this and other differences when it comes to deployment?

like image 276
And Finally Avatar asked Jan 03 '16 13:01

And Finally


1 Answers

You could mount your custom nginx.conf into the container in development via e.g. --volume ./nginx/nginx.conf:/etc/nginx/nginx.conf and simply omit this parameter to docker run in production.

If using docker-compose, the two options I would recommend are:

  • Employ the limited support for environment variable interpolation and add something like the following under volumes in your container definition: ./nginx/nginx.${APP_ENV}.conf:/etc/nginx/nginx.conf

  • Use a separate YAML file for production overrides.

like image 95
Evgeny Chernyavskiy Avatar answered Oct 21 '22 17:10

Evgeny Chernyavskiy