docker/machine — pull request #38 by dduportal (2014-12-07 12:03:36+00:00)
Title: Proposal: pass env vars and custom options to the Docker Daemon 

Hi guys !

I'm in this use case : virtual box dev only, for running docker + fig stack (and docker compose in near future).

We are facing two issues :
- Ours b2d virtualbox's machines will run behind the corporate http_proxy to access the internet
- We have a private internal registry which in running with no certificate : so, we'll have to add an ```--insecure-registry```switch to the DOCKER_OPTS

While one can just access the vbox machine, configure the /var/lib/boot2docker/profile file, it seems simpler to have easy configuration possibilities.

Given that, here is a proposal (early stage, need to discuss a bit before implementing) for passing docker options to the daemon, and passing env vars.

# Usage of the all thing :

I've written a little bit of doc, in order to approach the proposal from the user point of view. See the latest rendered version here : https://github.com/dduportal/machine/tree/proposal-conf-daemon-and-env-vars#configuring-the-docker-options-and-environment

## Direct passing to the command line using switches :

The idea is to define two switches that the *machine* command will use the fetch the custom options and inject them inside the newly created machine.
- ```--docker_opts``` will a be a single KVP switch, its content will be append to the DOCKER_OPTS variable and applied to the Daemon.
- ```--env``` will be a collection of kvp, in the same philosophy of the ```-e```switch of docker run command. (*Maybe* we can use a ```-e```switch and docker-run-syntax too in order to stay homogeneous ?)

## Using a config file
I'm thinking about also using a config file (~/.machine_config for default and ```--config-file``` switch for custom file when dealing with a bunch of machines).

I haven't written any doc yet around the config file because i don't what and how to choose the correct syntax and i need help :
- INI-like file, with a global section for all machines, and specific sections (by driver, by machines, maybe by users or label)
- Same in YAML syntax ?
- Simple KVP text file ?
- Other idea ?

My preference is going to a YAML format, which seems homogeneous with the new docker compose core functionality.

# Implementation :

Here also, we have some things to think about, given that we are going to have a lot of target drivers AND OSes.

## Docker OPTS

We need to have a configurable and overload-able method in order to append DOCKER_OPTS, where we should :
- Associate file path of where to configure depending on the target OS (or at least the managing services system used) : *boot2docker* => var/lib/boot2docker/profile, *ubuntu* => /etc/init/docker.conf, etc.
- The docker restart command : *boot2docker* => ```sudo /etc/init.d/docker restart```, *ubuntu* => ```sudo service docker restart```, etc.
- Conflict policy : i think we should do like in the init script of boot2docker : simply appending, which will overload the maybe-already-existing arguments

## Env vars

Same comment, because it depends what the user have in its mind. In my use cas, i just want to pass http_proxy and no_proxy variables to the context of the docker daemon and reload it.

But what if the user is starting up a machine based on a generic OS image and want machine to install docker inside ? Maybe it is outside the scope ? ut in this case, maybe the user want http_proxy to be accessible for its install processes and shell (bash, package manager, curl, etc.).
Any advise ?

My personal tough is : write that idea, make it outside the first scope, and saw if user try that or not.