Search code examples
containersibm-cloud

Share a service from Bluemix container to Bluemix app


I'm planning to expose a service from a container running in Bluemix containers, to a Bluemix application. I can find lots of documentation about doing it the other way round (binding apps to containers), but not anything about binding containers to apps.

My current plan is just to write a user-provided service which includes the public IP address of my container in its credentials, but this will be vulnerable to changes in the public IP address. Is it possible to do something similar to what's described in the docs for the --link option, and assign a name to a container and then address that container by an alias from an app? Or is there some other way I can do it which won't require updating app service credentials when the IP address of my container changes?


Solution

  • The --link option will only work between containers, for your scenario I recommend you to use a container group. Your container group can have one or more containers (for load balancing and high availability if needed).

    When you create a container group you can specify a route, similar to when you create a Bluemix Cloud Foundry application, no need to bind it to an IP address like single containers. For example, if you create a container group with route mycontainergroup you can access it using the following URL:

    http://mycontainergroup.mybluemix.net

    You can create a container group in the Bluemix dashboard or using the cf ic command line interface.

    To create using the cli use the cf ic group command, for example to create a container group using the default Liberty image:

    cf ic group create -p 9080 --name mycontainergroup registry.ng.bluemix.net/ibmliberty
    

    Check the documentation below for instructions on how to create containers group via the Bluemix dashboard:

    https://www.ng.bluemix.net/docs/containers/container_creating_ov.html#container_group_ov