Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify environment variables in the config to be used on each host through REST API #1328

Closed
munk opened this issue Mar 24, 2015 · 14 comments
Closed

Comments

@munk
Copy link

munk commented Mar 24, 2015

Right now, when I deploy a docker container to a host with the rest API, I can specify the hostname using a request body like this:

{
    ...,
    "container": {
        "docker": {
            ...
            "parameters": [
                { "key": "hostname", "value": "a.corp.org" },
               ...,
            ]
        },
        "type": "DOCKER",
        "volumes": []
    },
    ...
}

I would like to be able to specify a environment variable on the host for a parameter. Specifically, Mesos provides a $HOST variable that I'd like to use. I'd like to do something like this:

"parameters": [
                { "key": "hostname", "value": "$HOST" },
               ...,
            ]

But now this results in the hostname being set to the literal string "$HOST". I can imagine there are other use cases for having host specific environment variables used on each configuration.

@nickpoorman
Copy link

+1

@aquamatthias
Copy link
Contributor

Hey @jdowns you can use the env parameter in app.json for specifying environment variables.
This env Variables will be expanded in the cmd and are available in the docker.
However all other places in the json this expansion does not take place and would (probably) break compatibility.

@memelet
Copy link

memelet commented Jun 2, 2015

This is too bad. I'm trying to pass the $HOST to docker as the --dns argument:

        parameters:
          - {key: dns, value: "$HOST"}

I have consul running on each slave and need for the container to get access to it. As it is I have no way for my container apps to run in mesos/marathon.

@kriss9
Copy link

kriss9 commented Jul 16, 2015

+1

@memelet
Copy link

memelet commented Sep 16, 2015

@aquamatthias said:
Hey @jdowns you can use the env parameter in app.json for specifying environment variables.
This env Variables will be expanded in the cmd and are available in the docker.

But this seems not to be the case. For example if I specify an env XYZ_PORT = $PORT at runtime the value for XYZ_PORT is the string $PORT.

@bradleyreeves
Copy link

+1
"Hey @jdowns you can use the env parameter in app.json for specifying environment variables.
This env Variables will be expanded in the cmd and are available in the docker."

This is true, yet @munk 's core use case is being able to specify the value of the hostname the app is running on. Is this feasible? Define it to be resolved later on when a task is started on a particular machine?

@krestjaninoff
Copy link

+1
Is there any architectural reason to not implement this? Do you think that information about current host brakes isolation of an application/container?

@bradleyreeves
Copy link

Maybe a separate issue should be opened that isolates functionality of hostname resolution in env variables.

Edit:
new issue opened to specifically address this problem
#2679

@moricard
Copy link

moricard commented Apr 5, 2016

+1

3 similar comments
@JianTangAxa
Copy link

+1

@raveeolee
Copy link

+1

@mohamedhaleem
Copy link

+1

@aquamatthias
Copy link
Contributor

@nfnt Is there a way for the Mesos containerizer to set the hostname for docker containers?

@nfnt
Copy link
Contributor

nfnt commented Sep 20, 2016

No, the Mesos containerizer doesn't have such a feature.

@mesosphere mesosphere locked and limited conversation to collaborators Mar 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests