【问题标题】:How can I see my VCAP_SERVICES environment variable with the cf program?如何使用 cf 程序查看我的 VCAP_SERVICES 环境变量?
【发布时间】:2015-04-09 22:56:05
【问题描述】:

当我运行cf env <app-name> 时,它会显示我使用cf set-env 设置的所有环境变量,但我看不到VCAP_SERVICES 环境变量。如何查看该变量的值?

【问题讨论】:

  • cf 环境 APP_NAME

标签: cloud-foundry ibm-cloud


【解决方案1】:

cf 程序的 6.10 版开始,VCAP_SERVICES 环境现在将与其他环境变量一起显示,使用命令 cf env <app-name>

要升级您的cf 程序,请在发布页面下载相应版本:https://github.com/cloudfoundry/cli/releases

【讨论】:

    【解决方案2】:

    使用 cf env 命令查看应用程序的 Cloud Foundry 环境变量。 cf env 显示以下环境变量:

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

    详情请参考:

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

    【讨论】:

      【解决方案3】:

      cf env app-name 给出 VCAP_SERVICES 值。

      【讨论】:

        【解决方案4】:

        这里是小sn-p列出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"
        }
        }
        

        【讨论】:

          【解决方案5】:

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

          【讨论】:

            猜你喜欢
            • 2014-09-01
            • 1970-01-01
            • 1970-01-01
            • 2019-12-12
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-10-17
            • 2021-12-29
            相关资源
            最近更新 更多