Deploying to IBM Bluemix using a Docker Container

Prerequisites for Bluemix deployment

Note
Some notes about your Bluemix account

After you’ve logged into Bluemix on the web, your active region, organization, and space are shown in the top right-hand corner. You’ll need these three values in the following steps.

BluemixRegionOrgSpace.png

See the Bluemix documentation for more information on Bluemix organizations and spaces.

Log in using the cf command

See the IBM Bluemix Container Service plug-in documentation for the latest instructions, what follows is the TL;DR version:

  1. Login to Bluemix via the command line:

    cf login
    • Enter Bluemix API endpoint (for your region):

      • US South: https://api.ng.bluemix.net

      • London: https://api.eu-gb.bluemix.net

      • Sydney: https://api.au-syd.bluemix.net

    • Enter email and password for Bluemix login

      • If logging in with a federated ID (if you don’t know what this means, you aren’t), use the -sso option with a one-time use password

    • Choose a Bluemix organization by number

    • Choose a Bluemix space by number

  2. If this is your first time logging in to Bluemix, or using the IBM Container service, create a namespace. This step happens only once, and can’t be changed, so choose well.

    cf ic namespace set <my_namespace>
    • Use only letters, numbers, or underscores

    • Use 4 to 30 characters

  3. Initialize required keys and certificates for the Bluemix docker image registry:

    cf ic init

Add the docker image to the IBM Container service registry

  1. Use cf ic commands to build the docker container and push it into the Bluemix registry. Use the -t <tagName> option to tag the image.

    • For the sample-room-java project, from the application root directory:

      cf ic build -t gojava .
  2. Verify that your image is in the Bluemix registry:

    cf ic images

See the Bluemix documentation for more information about pushing local images to the Bluemix Registry.

Deploy a single container

  1. Start the container by running the command cf ic run. You can find the full path to the image from the output of cf ic images.

    • For the sample-room-java project, as an example:

      cf ic run -p 9080 --name gojava registry.ng.bluemix.net/<your-org>/gojava
  2. Bind a public IP address to your container

    • Get a public IP address

      cf ic ip request
    • Bind it to your running container:

      cf ic ip bind <ip address> <tagName>
  3. Check the status of your container

    cf ic ps

    Wait for it to switch from "Networking" to "Running"

  4. Use the public IP address to visit your running container

    • For the sample-room-java project, use http://<ip-address>:9080/.

    • Copy the websocket endpoint address. Use this address in your room registration.

Deploy as a container group

Instead of deploying a container as a single instance, you can instead deploy a container group. A container group load balances between multiple instances of the same container.

  1. Create the container group:

    cf ic group create -p 9080 -n <appName> --name <groupName> <registry>/<namespace>/<tagName>

    You can find the full path to the image from the output of cf ic images.

    • For the sample-room-java project, an example would be:

      cf ic group create -p 9080 --name gojavagroup registry.ng.bluemix.net/<org-name>/gojava
  2. Make sure your group has been created:

    cf ic group list

    "CREATE_COMPLETE" means the group has been created.

  3. Define a route to make your containers publicly available at <appHost>.mybluemix.net:

    cf ic route map -n <appHost> -d mybluemix.net <groupName>
  4. Check the status of your instances

    cf ic group instances <groupName>

    Once they are in "Running" state your group is ready to use.

  5. Go to http://<appHost>.mybluemix.net to access your application.

results matching ""

    No results matching ""