How can I see my VCAP_SERVICES environment variabl

2019-07-21 04:19发布

问题:

When I run cf env <app-name> it shows all the environment variables I've set with cf set-env, but I don't see the VCAP_SERVICES environment variable. How can I see that variable's value?

回答1:

As of version 6.10 of the cf program, the VCAP_SERVICES environment will now be displayed with the other environment variables, with the command cf env <app-name>.

To upgrade your cf program, download the appropriate version on the releases page: https://github.com/cloudfoundry/cli/releases



回答2:

cf env app-name gives VCAP_SERVICES values.



回答3:

Use the cf env command to view the Cloud Foundry environment variables for your application. cf env displays the following environment variables:

The VCAP_SERVICES variables existing in the container environment
The user-provided variables set using the cf set-env command

For details please refer:

http://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html



回答4:

cf env your-app-name gives VCAP_SERVICES values, but only when your application was bonded with service, else you will have only VCAP_APPLICATION variable.



回答5:

Here is the small snippet to list all the environment variables of PCF:

cf ssh <App_Name> -c "python -c 'import os, json; print(json.dumps({key:value for (key,value) in os.environ.items()}, indent = 2))'"

{
"INSTANCE_GUID": "315c18fb-e031-4e6e-67c4-84d1",
"CF_INSTANCE_PORT": "61064",
"CF_INSTANCE_KEY": "/etc/cf-instance-credentials/instance.key",
"USER": "vcap",
"INSTANCE_INDEX": "0",
.
.
.
.
"PWD": "/home/vcap",
"VCAP_APP_PORT": "8080"
}
}