I am trying to run a Consul container on each of my Mesos slave node.
With Marathon I have the following JSON script:
{
    "id": "consul-agent",
    "instances": 10,
    "constraints": [["hostname", "UNIQUE"]],
    "container": {
        "type": "DOCKER",
        "docker": {
            "image": "consul",
            "privileged": true,
            "network": "HOST"
        }
    },
    "args": ["agent","-bind","$MESOS_SLAVE_IP","-retry-join","$MESOS_MASTER_IP"]
}
However, it seems that marathon treats the args as plain text.
That's why I always got errors:
==> Starting Consul agent...
==> Error starting agent: Failed to start Consul client: Failed to start lan serf: Failed to create memberlist: Failed to parse advertise address!
So I just wonder if there are any workaround so that I can start a Consul container on each of my Mesos slave node.
Update:
Thanks @janisz for the link.
After taking a look at the following discussions:
#3416: args in marathon file does not resolve env variables
#2679: Ability to specify the value of the hostname an app task is running on
#1328: Specify environment variables in the config to be used on each host through REST API
#1828: Support for more variables and variable expansion in app definition
as well as the Marathon documentation on Task Environment Variables.
My understanding is that:
"cmd". But those environment variables are Task Environment Variables provided by Marathon, not the environment variables on your host machine.Please correct if I was wrong.
You can try this.
{
    "id": "consul-agent",
    "instances": 10,
    "constraints": [["hostname", "UNIQUE"]],
    "container": {
        "type": "DOCKER",
        "docker": {
            "image": "consul",
            "privileged": true,
            "network": "HOST",
            "parameters": [
                "key": "env",
                "value": "YOUR_ENV_VAR=VALUE"
            ]
        }
    }
}
Or
{
    "id": "consul-agent",
    "instances": 10,
    "constraints": [["hostname", "UNIQUE"]],
    "container": {
        "type": "DOCKER",
        "docker": {
            "image": "consul",
            "privileged": true,
            "network": "HOST"
        }
    },
    "env": {
        "ENV_NAME" : "VALUE"
    }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With