Bluemix create container group linking to another container

We have a Java application running with MongoDB, each one in a different Bluemix container. Both are SINGLE Bluemix containers.

We want to serve the Java app using one of our subdomains:, which is already pointing to Bluemix. How can we do it?

  • Unexpected behaviour from awk in docker-machine
  • Create Docker image from existing Ubuntu + App
  • How to check if a voip server setup on docker is working or not?
  • Sign-in Sign-up form with Node+MySql Docker Container
  • Change Docker memory from the command line
  • Docker compose (v2) UnkownHostException

    Because the Java container needs to link to the Mongo container, we created both containers programmatically (we didn’t find in the UI a way to link a container to another container) like this:

    sudo bluemix ic run --name mongo-container -p 27017 -m 128
    sudo bluemix ic run --name java-container --link mongo-container:mongo -p 8080 -m 128

    This works well, but the Java app is only accessible through an ugly Blumix IP, not through as we want.

    What about using a Bluemix container GROUP (SCALABLE container in the UI)?

    Again, we don’t know how to link containers from the UI, so it should be something like

    sudo bluemix ic group-create --auto --name java-scalable -p 8080 -m 128 --hostname subdomain --domain

    BUT according to the documentation we cannot link a container group to a container, since there is no --link parameter.

    Back to the original question. How can we serve the Java app using

  • Alpine linux in docker container ignoring shell script arguments
  • boot2docker under proxy returns Forbidden
  • Error when creating a MySQL database in a Dockerfile
  • Node C++ extension loading in docker only Segfault on Google Compute Engine
  • How to use docker run with a Meteor image?
  • So many Binlog_dump connections in Processlist?
  • 2 Solutions collect form web for “Bluemix create container group linking to another container”

    The link option basically creates environment variables in one container to reach the other one.

    You can do the same with your scalable container in Bluemix.

    Here are the steps I did:

    1) Create your MongoDB container:

    bx ic run --name ads-mongo -p 27017 -m 128 

    2) Inspect the MongoDB container to find the private IP address:

    bx ic inspect ads-mongo

    The private IP will be at end of the output, I am adding just part of the output below for brevity:

      "Ports": {
                    "27017/tcp": [
                            "HostIp": "",
                            "HostPort": "27017"
                "PublicIpAddress": ""

    3) Run your scalable container and include one or more environment variables with your MongoDB credentials. Make sure you change your Java code to get the credentials from the environment variables you are passing to the scalable container:

    bx ic group-create --name ads-node -e "MONGO_URI=mongodb://" -p 3000 -m 128 --hostname ads-node --domain

    In my test I used a Node.js application and it reads the MONGO_URI environment variable for the MongoDB credentials.

    You can assign a public IP for your MongoDB container as well if desired, the end result should be similar. The only difference I see is that you can then access your db using mongo command line or other tools to connect to the database.

    So following the second approach, you may be able to create a MongoDB service before creating the Bluemix Container Group. During Bluemix Container Group creation you have the ability to bind an existing service under the Advanced Options section in the UI:

    enter image description here

    You can also choose to use a custom Domain during Container creation, if you have previously created one:

    enter image description here

    In this case you would have a container with a custom Domain that also includes an existing service.

    You can find more information about binding an existing service in the Container Integration Documentation. You can learn more about creating a custom domain in Bluemix in the Updating Apps Documentation.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.