1

I was trying to deploy ngnix docker container by mesos Marathon, I would like to set some environment variables in the container, so I added parameter section in the Json file, but after I added the parameter section, it was failed. My Json file as following:

{
  "container":{
    "type":"DOCKER",
    "docker":{
      "image":"nginx",
      "network":"BRIDGE",
      "portMappings":[{"containerPort":80,"hostPort":0,"servicePort":80,"protocol":"tcp"}],
      "parameters": [
                { "key": "myhostname", "value": "a.corp.org" }
            ]
    }
  },
  "id":"nginx7",
  "instances":1,
  "cpus":0.25,
  "mem":256,
  "uris":[]
}

my launch script was: curl -X POST -H "Content-Type: application/json" 10.3.11.11:8080/v2/apps -d@"$@"

The command I ran was: ./launch.sh nginx.json

Jack
  • 5,540
  • 13
  • 65
  • 113

1 Answers1

1

You used the wrong parameter key myhostname, if you want to setup hostname for you container, it should be:

"parameters": [
            { "key": "hostname", "value": "a.corp.org" }
        ]

if you want to pass environment variable, it should be:

"parameters": [
            { "key": "env", "value": "myhostname=a.corp.org" }
        ]
shizhz
  • 11,715
  • 3
  • 39
  • 49
  • Thank you, where I can find the documents about all of parameters keys please. – Jack Mar 30 '17 at 02:36
  • 1
    The value of `key` is actually option name of `docker run`, so using `"parameters": [ { "key": "hostname", "value": "a.corp.org" } ]` means it will run docker container like `docker run --hostname a.corp.org ...`. You could have a look at `docker help run` or refer to their official docs: https://docs.docker.com/engine/reference/run/ – shizhz Mar 30 '17 at 02:44