Over a million developers have joined DZone.

Docker and IBM Bluemix Containers Reference Sheet

For beginners to Docker and IBM Bluemix containers, use this reference sheet to help remember commonly used commands, including how to create Docker images.

· Cloud Zone

Download the Essential Cloud Buyer’s Guide to learn important factors to consider before selecting a provider as well as buying criteria to help you make the best decision for your infrastructure needs, brought to you in partnership with Internap.

As a developer I prefer graphical tools since I often cannot remember all the different commands for various CLIs (command line interfaces). In cases where I have to use CLIs I write down my own little cheatsheets with the commands I use most often. Below is a minimal set of commands to create Docker images and containers running a Java Liberty application and deploy them to IBM Bluemix.

For more information check out the official Docker CLI documentation and the IBM Containers CLI documentation. To interact with Bluemix I use below the IBM Container plugin for Cloud Foundry which you need to install in addition to Docker and the Cloud Foundry CLI.


List all images:
docker images

Remove image:
docker rmi _image_tag_

List all containers:
docker ps -a

Remove container:
docker stop _container_name_
docker rm _container_name_

Build image:
docker build -t _image_tag_ .

Run container:
docker run --name _container_name_ -p 80:80 -p 443:443 -d -t _image_tag_

Launch application:
boot2docker ip
browser: http:// _your_ip_

IBM Containers

cf login
cf ic login

List all images:
cf ic images

Remove image:
cf ic rmi registry.ng.bluemix.net/_your_namespace_/_image_tag_

List all containers:
cf ic ps -a

Remove container:
cf ic stop _container_name_
cf ic rm _container_name_

Push image:
docker tag _image_tag_ registry.ng.bluemix.net/_your_namespace_/_image_tag_
docker push registry.ng.bluemix.net/_your_namespace_/_image_tag_

Run container:
cf ic run --name container_name -p 80:80 -p 443:443 -d -t registry.ng.bluemix.net/_your_namespace_/_image_tag_

Manage IP addresses:
cf ic ip request
cf ic ip list -a
cf ic ip bind _your_ip_ _container_name_

Launch application:
browser: http:// _your_ip_

Sample Liberty Application

I've implemented a simple hello world Liberty application. In order to deploy it to Bluemix you can use the commands above. Here is the Dockerfile which copies the server configuration and the web application.

I've configured Liberty to use the ports 80 and 443, but you can also leave the defaults and change the port mappings in the commands above.

The Cloud Zone is brought to you in partnership with Internap. Read Bare-Metal Cloud 101 to learn about bare-metal cloud and how it has emerged as a way to complement virtualized services.


Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

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

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

{{ parent.tldr }}

{{ parent.urlSource.name }}