The link parameter basically creates environment variables in one container to access another.
You can do the same with your scalable container on Bluemix.
Here are the steps I took:
1) Create your MongoDB container:
bx ic run --name ads-mongo -p 27017 -m 128 registry.ng.bluemix.net/namespace/mongo
2) Check the MongoDB container for a private IP address:
bx ic inspect ads-mongo
The private IP address will be at the end of the output, for brevity, I add only part of the output below:
"Ports": { "27017/tcp": [ { "HostIp": "172.31.0.235", "HostPort": "27017" } ] }, "PublicIpAddress": ""
3) Launch a scalable container and include one or more environment variables with your MongoDB credentials. Make sure you change the Java code to get the credentials from the environment variables that you pass into the scalable container:
bx ic group-create --name ads-node -e "MONGO_URI=mongodb://172.31.0.235:27017" -p 3000 -m 128 --hostname ads-node --domain mybluemix.net registry.ng.bluemix.net/namespace/ads-nodebx
In my test, I used the Node.js application and read the MONGO_URI environment MONGO_URI for MongoDB credentials.
You can assign a public IP address for your MongoDB container, if you want, the end result should be similar. The only difference that I see is that you can access your db using the mongo command line or other tools to connect to the database.
source share