mamacdon
mamacdon

Reputation: 3189

Bluemix: service bound to container does not appear in VCAP_SERVICES

I'm trying to use IBM Containers for Bluemix to deploy a container and bind it to a Bluemix service.

I start with an existing Bluemix app, which is bound to the MongoDB service I want. I verify that its VCAP_SERVICES environment variable is correctly populated:

$ cf env mamacdon-app
Getting env variables for app mamacdon-app in org [email protected] / space dev as [email protected]...
OK

System-Provided:
{
    "VCAP_SERVICES": {
        "mongodb-2.4": [
            {
                "credentials": { /*private data hidden*/ },
                "label": "mongodb-2.4",
                "name": "mongodb-1a",
                "plan": "100",
                "tags": [ "nosql", "document", "mongodb" ]
            }
        ]
    }
 ...

Then I run my image in Bluemix using the ice command, with the --bind mamacdon-app argument to bind it to my CF app:

$ ice run --name sshparty \
  --bind mamacdon-app \
  --ssh "$(cat ~/.ssh/id_rsa.pub)" \  # For SSH access
  --publish 22 \                      # For SSH access
  registry-ice.ng.bluemix.net/ibmliberty:latest

As the name suggests, the image is a trivial example based on the IBM Websphere Liberty docker image -- just enough to let me SSH in and poke around.

At this point, the Containers dashboard tells me that the service has been bound to my container:

Dashboard showing bound service

But when I finally ssh into the container, the environment does not contain the VCAP_SERVICES variable:

$ ssh -i ~/.ssh/id_rsa [email protected]
root@instance-000123e2:~# env
TERM=xterm
SHELL=/bin/bash
SSH_CLIENT=[private data hidden]
SSH_TTY=/dev/pts/0
USER=root
LS_COLORS=[omitted]
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/root
LANG=en_CA.UTF-8
SHLVL=1
HOME=/root
LOGNAME=root
SSH_CONNECTION=[private data hidden]
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
root@instance-000123e2:~#

I expected the VCAP_SERVICES variable to be injected. What am I doing wrong?

Upvotes: 0

Views: 500

Answers (2)

lmsurprenant
lmsurprenant

Reputation: 1925

I think there is an issue with the way the ssh daemon is getting launched where it does not have visibility to the VCAP_SERVICES environment variable.

However, you can confirm that the container's command will see the variable with following test:

ice run registry-ice.ng.bluemix.net/ibmliberty --bind mamacdon-app --name vcap_services_party printenv; sleep 60

Then, confirm it in the printenv output with ice logs vcap_services_party

Upvotes: 1

Jeff Sloyer
Jeff Sloyer

Reputation: 4964

Could you give the following a try:

ice run registry-ice.ng.bluemix.net/lintest/tradelite --bind yourappname --name yournewcontainer name

Once the image comes up run the following.

# echo $VCAP_SERVICES

For more info check out the Containers Docs.

Upvotes: 0

Related Questions