mesosphere-backup / deimos

Mesos containerizer hooks for Docker
Apache License 2.0
249 stars 26 forks source link

deimos not picking up additional options for the run command from config #22

Closed yashvyas closed 10 years ago

yashvyas commented 10 years ago

I am trying to pass the -e option for docker run via the deimos config file to set up some environment variables.

My config file looks like this

mesos@mesos-5:~$ cat /usr/local/etc/deimos.cfg 

[docker]
# These are options passed to Docker *before* the call to run/images/&c. This
# allows you to set the Docker host. Note that any key:value pair whatever can
# be set here. If the syntax of a key is such that it resembles a JSON list,
# the option will be passed multiple times, once for each item in the list.
host: ["unix:///var/run/docker.sock"]

[docker.index]
account_libmesos: libmesos
#account: guilhem 
index: index.docker.io

[containers.options]
# This array of options is passed to 'run' if there are none in the TaskInfo.
default: []
# These options are passed to 'run' in addition to those in the TaskInfo.
append: ['-e JAVA_HOME=java-6-openjdk-amd64']
# This flag causes all container options in the TaskInfo to be ignored.
ignore: false

[containers.image]
# The image to use when none is specified in the TaskInfo.
default: docker:///centos
# Causes Deimos to ignore the container image specified in the TaskInfo.
ignore: false

[uris]
# When false, Deimos will leave Tar and Zip archives as-is after download.
unpack: True

[log]
# Enable syslog and set its log level.
syslog:  DEBUG
# Enable console logging and set its log level.
console: DEBUG

[state]
root: /tmp/deimos

The output of deimos config is :

mesos@mesos-5:~$ deimos config
07:16:00.868 deimos.config.load_configuration() Loaded configuration from /usr/local/etc/deimos.cfg
07:16:00.868 deimos.config.load_configuration() Found: deimos.config.Docker(host=[u'unix:///var/run/docker.sock'])
07:16:00.869 deimos.config.load_configuration() Found: deimos.config.State(root='/tmp/deimos')
07:16:00.869 deimos.config.load_configuration() Found: deimos.config.Containers(image=deimos.config.Image(ignore=False, default='docker:///centos'), options=deimos.config.Options(ignore=False, default=[], append=[]))
07:16:00.869 deimos.config.load_configuration() Found: deimos.config.Log(syslog=10, console=10)
07:16:00.870 deimos.config.load_configuration() Found: deimos.config.DockerIndex(account_libmesos='libmesos', index='index.docker.io', account=None)
07:16:00.870 deimos.cli() Final configuration:
deimos.config.DockerIndex(account_libmesos='libmesos', index=None, account=None)
deimos.config.Log(syslog=10, console=10)
deimos.config.URIs(unpack=True)
deimos.config.State(root='/tmp/deimos')
deimos.config.Docker(host=[u'unix:///var/run/docker.sock'])
deimos.config.DockerIndex(account_libmesos='libmesos', index='index.docker.io', account=None)
deimos.config.Containers(image=deimos.config.Image(ignore=False, default='docker:///centos'), options=deimos.config.Options(ignore=False, default=[], append=[]))
yashvyas commented 10 years ago

From user mhamrah :

The append option in the config file tripped me up as well, check the sys logs to see how Deimos is parsing the array. It could be adding unnecessary spaces, and you need to restart mesos-slave after you make the change.

This worked for me:

/etc/deimos.cfg

[containers.options] append: ["-e", "HOST_IP=192.168.33.12"]

This works for me! Thanks. Although maybe it could be set in the example.cfg or documented.