In this tutorial you will take the same sample application used in the Working with Related Containers tutorial and deploy it to the IBM Containers service running on IBM Bluemix.
To complete this tutorial you will need an IBM ID registered with IBM Bluemix. If you do not have an IBM ID, or have not signed up for Bluemix, and wish to complete this section of the lab then sign up for a free 30-day trial. You will then need the Cloud Foundry CLI with the IBM Containers plug-in installed.
-
Log in IBM Bluemix using the Cloud Foundry CLI. You will be prompted to provide your IBM ID and password.
$ cf login -a https://api.ng.bluemix.net
-
If you haven't use IBM Containers before, you need to specify a unique registry namespace to use with your account. In the following command, substitute a value for that must be a combination of lower-case letters and numbers, and must start with a letter.
$ cf ic namespace set <namespace>
-
Initialize the IBM Containers plugin:
$ cf ic init
Note: When the init command is run you will be presented with two options. Option one allows you to simultaneously manage IBM Containers and your local Docker host through 'cf ic' commands. Option two uses the Docker CLI, overriding the local Docker environment to connect to IBM Containers. This tutorial will use the first option.
4. Copy the MongoDB Docker Hub image to your private registry, remembering to insert your namespace.
```bash
$ cf ic cpi mongo registry.ng.bluemix.net/<namespace>/mongo
```
-
Run an instance of the Mongo image that you just copied across called mongodb
$ cf ic run -d --name mongodb registry.ng.bluemix.net/<namespace>/mongo
-
Change to the
bluemix
directory containing this README.$ cd bluemix
-
Look at the Dockerfile that will be used to build the application image using the following command. Notice the base image being used is the
ibmliberty
image that is published in the IBM Containers registry.$ cat Dockerfile
-
Build the app in IBM Containers, remembering to insert your namespace once again:
$ cf ic build -t registry.ng.bluemix.net/<namespace>/app .
-
Run the app that you just built, linking the mongodb container.
$ cf ic run -d --link mongodb:db -p 80:9080 --name app registry.ng.bluemix.net/<namespace>/app
-
Check all the containers are up and running:
$ cf ic ps
-
Access the application using the allocated IP address.
$ curl $(cf ic port app 9080)/mongoDBApp
-
Clean up the containers and images with the following commands:
$ cf ic kill $(cf ic ps -aq) $ cf ic rm $(cf ic ps -aq) $ cf ic rmi registry.ng.bluemix.net/<namespace>/app $ cf ic rmi registry.ng.bluemix.net/<namespace>/mongo
Congratulations on completing this tutorial.