Getting to Docker and then IBM Containers on Bluemix
Just brief notes so I can do it a second time. Posted here for you.
Create an account on Docker Hub.
https://hub.docker.com
Read up on docker while you're there.
You need Linux. Although you can do a lot of this on Windows/Mac I guess too.
In hindsight - I only needed linux because I was building a linux app that I then moved into a docker image.
If you don't have linux download VirutalBox and install it.
Then download the ubuntu iso file. http://www.ubuntu.com/download/desktop
Create an ubuntu image on VirtualBox
- New.. type=Linux, Version=Unbuntu
- I had to drop into expert mode and set my disk size to 10GB. The Guest Additions (see below) take up space, but they're useful.
- Maybe set memory to 3GB
- it will ask you the location of your ubuntu.iso file.
- When Ubuntu starts click on the devices menu, and install guest additions. This is what makes shared clipboard work.
later on...
- In VirtualBox settings/general/advanced set share to clipboard = bidirectional
- in VirtualBox settings/network maybe set to bridged adapter if you plan on hitting a docker webservice from your host machine.
In Ubuntu
open a commmand window (CTRL ALT T)
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker <username>
logout and then login again
At this point you can follow the excellent docker tutorials on docker.com
They will talk you through building a Docker image.
The mistake I made when I built mine was in the FROM clause in the Dockerfile. BlueMix only supports certain OSs. I had Alpine:3.4 in my FROM clause. I changed it to Ubuntu:16.04 and my project sprang to life on Bluemix. Knowing this will keep you out of trouble if your goal is to push to Bluemix. Docker itself has more options than bluemix in this regard.
After reading up and creating your Dockerfile
docker build -t <mynamespace/myappname> . <-- this will build your docker image. DO NOT MISS the period at the end
docker run -P <mynamespace/myappname> <-- the -P tells it to open ports that you've EXPOSE'd in your Dockerfile config
Push to docker hub and share
docker login <-- gets you to your docker hub
docker push <mynamespace/myappname>
Congratulations! You've built and shared a docker image
Push to IBM Containers on Bluemix
Still in Ubuntu
Open a browser and go to https://github.com/cloudfoundry/cli/releases
Select the CF CLI of your choice. If you're following the unbuntu thread here, just grab the Debian 64 bit.
Install the IBM Container plugin to CF
cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x64
Login to Bluemix via CF
cf login -a api.ng.bluemix.net
cf ic init
cf ic namespace <-- remember your namespace
Push your docker image to bluemix from your dockerhub
cf ic cpi namespace/program registry.ng.bluemix.net/namespace/program:new
From any machine:
Configuring your docker image on Bluemix
Open a browser
Login to Bluemix
Go to Catalog
Go to Compute
Go to Containers
You should see your image listed. It should have a green checkbox next to it. If not, there's a problem and you can't go further.
Click on your image to configure a container.
Give it a name, use the smallest size possible, probably pico, request a public IP or not, wait for it to launch and start up.
Congratulations! You've built a docker container and pushed it to IBM Containers on Bluemix!