Wednesday, April 27, 2016

Bluemix Containers - Hello BusyBox

BusyBox can be used as a lightweight Docker image to run a set of UNIX tools and test that Docker has been configured properly.  This document demonstrates running the BusyBox Docker image in IBM Bluemix.  

 

Create an IBM Bluemix account

    IBM Bluemix can be used with a free trial account by signing up on https://bluemix.net/.  Sign up for IBM Bluemix to start using Bluemix and Bluemix Containers.

Getting started with Bluemix Containers

    Bluemix Containers requires a Docker Engine installation, along with Cloud Foundry CLI and the IBM Containers Extension.  See the official Bluemix Documentation for additional configuration/installation details.


Install Docker Engine
    Details for installing Docker Engine: https://docs.docker.com/engine/installation/
Install Cloud Foundry CLI
    cd /usr/bin    
    curl -L "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar -zx
Install IBM Containers Extension

 

Run your first image using Bluemix Containers

    The following steps document how to run an interactive BusyBox example using Bluemix Containers.
Login to Bluemix using Cloud Foundry CLI:
    cf login -a api.ng.bluemix.net
        Email> (Bluemix account email)
        Password> (Bluemix account password)
        Org> (Bluemix account org)
Login to IBM Containers:
    cf ic login
List the Bluemix Container namespace:
    cf ic namespace get
Set the Bluemix Container namespace (if not already set):
    cf ic namespace set <Namespace>
Pull the latest BusyBox image locally from Docker Hub: https://hub.docker.com/_/busybox/
    docker pull busybox:latest
Prepare the BusyBox image with tags matching your Bluemix Container namespace:

    docker tag busybox:latest registry.ng.bluemix.net/example/busybox:latest

Push the image to your Bluemix Registry:   
    docker push registry.ng.bluemix.net/<Namespace>/busybox:latest

Run the BusyBox Docker container using Bluemix Containers:
    cf ic run -it registry.ng.bluemix.net/example/busybox:latest

Execute any BusyBox command from the running container: Busybox commands reference.  Type exit to quit the BusyBox container session.

Next steps

    Now that you have successfully ran the BusyBox Docker image using Bluemix Containers, you can run other Docker images on Bluemix.  Try pulling another public image from Docker Hub, or building your own Docker image using a Dockerfile.