简体   繁体   中英

How can I see my VCAP_SERVICES environment variable with the cf program?

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?

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

cf env app-name提供VCAP_SERVICES值。

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

cf env your-app-name提供VCAP_SERVICES值,但仅当您的应用程序与服务绑定时,否则您将只有VCAP_APPLICATION变量。

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"
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM