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?

  • Can I put my docker repository/image on GitHub/Bitbucket?
  • Docker Ignores limits.conf (trying to solve “too many open files” error)
  • docker swarm 1.1.3: No such image after pulling from public repo, and trying to tag
  • Docker Images Hierarchy
  • Storing and analyzing electricity and payment data in open source DB
  • Configure a user to access Parse Dashboard remotely

    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

  • Bunyan logger on aws leaks file descriptors
  • How to build stateful docker services architecture with CoreOS's fleet?
  • Make Docker image error
  • Error running quickstart-camelservlet in OpenShift V3 with Fabric8 and Docker
  • When, where and how does Visual Studio 2017 set the DOCKER_BUILD_SOURCE environment variable
  • Why do I get an authorization error from Docker when I'm trying to pull a public image?
  • 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.