Overview

Skill Level: Any Skill Level

Bluemix DevelopersBluemix Architectes

IntroductionIn the previous article on custom docker image creation we have seen how to create a docker image locally on your machine using commandline. But this will require this image to be uploaded to Bluemix container environment which will take considerable bandwidth and time as upload internet speeds are quite less and on many occasions […]

Ingredients

Understanding of Bluemix

Understanding of Dockers

Step-by-step

  1. Introduction

    In the previous article on customer docker image creation we have seen how to create a docker image locally on your machine using commandline. But this will require this image to be uploaded to Bluemix container environment which will take considerable bandwidth and time as upload internet speeds are quite less and on many occasions the size of the image is big. Hence the upload may take hours to complete, thereby delaying the solution delivery. This article is an extension to previous article and show case how one can with the help of external FTP server and DevOps delivery pipeline one can get rid of pain to reference binaries URL which are subjected to change time to time resulting in failure of Docker build commands. Finding the URL’s is a pain as for many of the open source binaries URL’s are not available. Using a fixed FTP server could also help in referencing propritory softwares direclty from Bluemix. The benefit of this approach is one can have a permanent location with flexibility to refer Images with fixed URL which other wise are changing regularly on vendors sites due to their archival or versioning. This article is using anonymous login to ftp but one can go for secured login aswell.

  2. Setting up FTP server

    In this article public FTP service provider Hosted ~FTP~ (https://hostedftp.com) server is being is used. This article has make use of trial account with 1GB limit but for production or long term use one can take subscription from this vendor. To start with one needs to create an account and login credentials at their site.

    Create a folder and upload necessary binaries in this folder and make it share anonymous by going into Sharing tab for credential less download. One can also opt for authenticated download and use wget or curl commands accordingly. For this article anonymous login is been used.

    To share the folder anonymously one needs to goto Sharing tab beside Home and select relevant options as shown below.

    After one saves the above configuration one can see the below details.

    Verify the ftp URL by clicking browse button in figure above, this will open a new browser window showing content uploaded in ftp server. As shown below our URL of interest is ftp://middleware.hostedftp.com/~binaries/wildfly10/

    The above URL will be used in our docker file to pull in the data to build docker Image. One can create alias (~binaries) for URL by going into setup and pressing change button.

    We are now ready with ftp configuration, lets test this on putty before referencing URL in dockerfile.

    Once verified we can go ahead and reference the URL in Dockerfile

    The architecture will be as below

    Rest of the things in Dockerfile will remain the same as explained in article:

    https://developer.ibm.com/recipes/tutorials/creating-custom-docker-image-with-ibm-containers/

    One can find Dockerfile here:

    https://github.com/sharadc2001/DevOps

    For setting up GitHub and Jazz Hub projects and linking then reference the below article:

    https://developer.ibm.com/recipes/tutorials/binding-bluemix-services-to-ibm-containers-using-delivery-pipeline/

  3. Creating Build and Deploy pipeline using DevOps

    To build and deploy docker Image from scratch from a Dockerfile one needs to make use of Delivery Pipeline as shown below. This will help run docker build and docker run commands automatically.

    To start with one needs to click this short cut and deploy this service in their Bluemix workspace.

    Note: It is assumed that one has already setup JazzHub account along with Github and uploaded Docker assets in respective repositories.

    Add Build Stage

    Add Deploy Stage

    Now our stages are ready to run. The two stages are linked to each other i.e after Build stage is completed, deploy stage runs automatically.

    We will start running the Build stage by clicking the button as shown above.

    After deploy is completed one can see the below result:

  4. Conclusion

    With the help of external ftp server and DevOps one can ease build and deploy of docker Images in Bluemix.

1 comment on"Creating custom docker image in Bluemix-PartII"

  1. Excellent and very much useful for the SI partners.

Join The Discussion