Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Getting Containerized via the Bluemix CLI

DZone's Guide to

Getting Containerized via the Bluemix CLI

Bluemix recently upped its Kubernetes support, but they haven't forgotten about Docker. If you like CLIs, you'll want to check out IBM Containers.

· Cloud Zone
Free Resource

Linkerd, the open source service mesh for cloud native applications. Get the complete guide to using Linkerd and Kubernetes to build scalable, resilient applications.

In this post, you will learn how to create and push a Docker container to Bluemix via the Bluemix CLI. This post includes:

  • Steps to set up and use the Bluemix CLI.
  • Creating and running your container on IBM Bluemix.

I have been exploring and playing with containers, more specifically Docker containers, for a while now, and I've been doing the same with IBM Cloud. But I just thought about exploring both worlds together. Then there came the option to create a container on Bluemix.

docker containers on Bluemix

Setting Up bx CLI

The Bluemix CLI is supported on all major operating systems. Just to keep the blog post compact and simple, I will be running all the commands on macOS terminal.

  • Bluemix Account – Signup / Login
  • Docker CLI
  • Before installing the Bluemix CLI, install Cloud Foundry's CLI
  • Download the Bluemix CLI from here 

Now, let's run through commands. For starters, here's the command to check whether Bluemix (bx) CLI is installed: bx

And to check the version of your installation: bx --version

And finally, to update your Bluemix CLI, run the command: bx update 

Plugins

Like Cloud Foundry's CLI, the Bluemix CLI supports a plugin extension framework to integrate other commands besides the built-in ones.

  • To install Bluemix CLI plug-ins from the Bluemix registry, set the plug-in registry endpoint:
bx plugin repo-add bluemix-bx https://plugins.ng.bluemix.net


  • Then, run the following command to install a IBM Container (ic) plugin:
bx plugin install IBM-Containers -r Bluemix-bx


Replace IBM-Containers with any plugin-name you want to install

To update a plugin, run the below command

To confirm that you are good to create a container via Bluemix CLI, run the below command

bx ic --help


Notebx stands for Bluemix and ic stands for IBM Containers.

You should see all the IBM container commands.

Creating Your First Container on Bluemix

Before creating your container on Bluemix, you should log in with the command:

Set the name of the private Bluemix image repository the organization that you are logged into.

Restriction: You can’t use a hyphen - in the name of your repository namespace.

bx ic namespace-set <namespace-name>


To read your namespace anytime, run the command: bx ic namespace-get

To check the images, run the command: bx ic images

Using the below command you can move an image from public registry like DockerHub to your private registry on Bluemix

bx ic cpi hello-world registry.ng.bluemix.net/<namespace-name>/hello-world


By running the above command you are copying hello-world image to your private registry under your own namespace.

Let’s run our container on Bluemix:

bx ic run -it registry.ng.bluemix.net/<namespace-name>/hello-world


Output:

Run this command to see all the containers under your private registry on Bluemix: bx ic ps -a.

You can run docker COMMAND –help for more information on Docker commands. Meanwhile, using bx ic help will do the same for for IBM Containers commands.

Use export BLUEMIX_TRACE=true or bluemix ic COMMAND -v|–verbose
[COMMAND OPTIONS] [ARGUMENTS…]
 to enable debug mode.

For a full list of CLI commands, see the IBM Containers documentation, and refer to this link for more Bluemix plugins,

In subsequent articles, you will see how to containerize an existing Node.js app (GitHub repo) by drafting a Dockerfile. Then, we'll run it on Bluemix. That will be followed by an introduction to the new IBM Container service and its CLI commands.

Linkerd, the open source service mesh for cloud native applications. Get the complete guide to using Linkerd and Kubernetes to build scalable, resilient applications.

Topics:
cloud ,ibm bluemix ,containerization ,docker ,tutorial

Published at DZone with permission of Vidyasagar Machupalli, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}