I'm using Marathon to run a Docker container, and am trying to set the DNS server for that container to point to a Consul agent on the local host.  Inside the container, Marathon/Mesos is setting environment variables (which can be used in "args"), but I need the IP address of the slave to pass to the --dns option on the docker run.  For example, this doesn't work, because the HOST variable can't be resolved:
{
    "id": "demo",
    "cmd": "python3 -m http.server 8080",
    "cpus": 0.5,
    "mem": 64.0,
    "instances": 2,
    "container": {
        "type": "DOCKER",
        "docker": {
            "image": "python:3",
            "network": "BRIDGE",
            "parameters": [{
                "key": "dns",
                "value": "$HOST"
            }],
            "portMappings": [{
                "containerPort": 8080,
                "hostPort": 0,
                "protocol": "tcp"
            }]
        }
    },
}
I've tried using an environment variable that the Mesos slave can access, but that doesn't seem to work either. Any suggestions?
                        
I have never tried to use the
$HOSTvariable in theparameterslist but you can use it in thecmdspecifier. You can do something like this:You will get the hostname or the ip address of your mesos slave as the first program argument in myscript.py.
In myscript.py you need to do the folowings:
Resolve the host name to ip address if the $HOST varaible contains host name.
Change the nameserver in /etc/resolv.conf like this: