3

How do I get the environment placeholders to show up inside a Docker container?

The documentation doesn't seem to be exactly clear where those can be used. I have tried to just set those inside the node env as shown in a JPS file that is added to this question.

For example, it shows the environment as env-2461411 and its name as Environment Test in the environment options

Once the environment is launched, the placeholders are still as they show in the JPS file, and not replaced by the actual values.

Result

Placeholders don't seem to be replaced, and as such the shell doesn't like the environment it gets:

-bash: ${env.appid}: bad substitution
-bash: ${env.displayName}: bad substitution
-bash: ${env.domain}: bad substitution
-bash: ${env.envName}: bad substitution
-bash: ${env.name}: bad substitution
-bash: ${env.shortdomain}: bad substitution
-bash: ${env.url}: bad substitution
-bash: ${env.appid}: bad substitution
-bash: ${env.displayName}: bad substitution
-bash: ${env.domain}: bad substitution
-bash: ${env.envName}: bad substitution
-bash: ${env.name}: bad substitution
-bash: ${env.shortdomain}: bad substitution
-bash: ${env.url}: bad substitution

Expected result

Environment variables showing in the bash environment, such as

env_domain=env-2461411
env_name=Environment Test 

Example JPS file

{
    "jpsType": "install",
    "jpsVersion": "1.4",
    "name": "Environment Test",
    "description":
    {
        "text": "Template for testing environment variables test",
        "short": "Environment variables test"
    },
    "logo": "https://raw.githubusercontent.com/jelastic-jps/start-stop-scheduler/master/images/logo.png",
    "homepage": "https://jelastic.com/",
    "categories":
    [
        "apps/testing"
    ],
    "success":
    {
        "text": "## Environment test is up and running\nOpen the Jelastic SSH gateway and locate the test-node, see its environment with `env`"
    },
    "nodes":
    [
        {
            "image": "debian",
            "extip": false,
            "count": 1,
            "cloudlets": 16,
            "fixedCloudlets": 1,
            "nodeType": "docker",
            "nodeGroup": "test",
            "displayName": "test-node",
            "volumes":
            [
                "/root"
            ],
            "env":
            {
                "env_appid": "${env.appid}",
                "env_domain": "${env.domain}",
                "env_url": "${env.url}",
                "env_displayname": "${env.displayName}",
                "env_envname": "${env.envName}",
                "env_name": "${env.name}",
                "env_shortdomain": "${env.shortdomain}"
            }
        }
    ],
    "onInstall":
    {
        "log": "${placeholders}"
    }
}
Mireiawen
  • 67
  • 3

1 Answers1

1

During the process of environment's creation mentioned placeholders are not initialized and can't be used. You can use the method AddContainerEnvVars. In your case, it will be like this.

Virtuozzo
  • 1,993
  • 1
  • 10
  • 13