Use Case: As a developer, I wish to create container images using JBDS and deploy them to OpenShift
Step 1: Switch to Docker perspective
On the top right of JBDS you will find icons to switch perspectives. Find the Docker Tooling icon that appears as a single blue cylinder. If you hover over the icons it should show the label Docker Tooling. You can also open this by going through menu options Window->Perspective->Open Perspective->Other and select Docker Tooling.
Step 2: Create a connection to the Docker Daemon running on the Minishift VM
Minishift runs a VM, and a docker daemon inside that VM. oc cluster up that is run by minishift pulls the OpenShift all-in-one and instantiates using this docker daemon. While you may have Docker running on your workstation (example Docker on Windows or Docker on Mac), Minishift doesn't use that daemon. In this step, we will connect to this daemon from JBDS.
- To find the connection details run the following command from your command line to gather minishift's docker connection details.
$ minishift docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.64.2:2376"
export DOCKER_CERT_PATH="/Users/veer/.minishift/certs"
export DOCKER_API_VERSION="1.24"
# Run this command to configure your shell:
# eval $(minishift docker-env)
Note the values for DOCKER_HOST and DOCKER_CERT_PATH. In my case they are
tcp://192.168.64.2:2376 and /Users/veer/.minishift/certs
- In the
Docker Explorer, press on theAdd Connectionicon (blue cylinder with a yellow + sign).
- This will open up
Connect to docker daemonwindow. Now provide aConnection nameand type in the connection parameters noted above forTCP Connection. CheckEnable Authenticationand provide theDOCKER_CERT_PATHnoted above.
-
Press on
Test Connectionto ensure that the connection is successful. Then press onFinish -
Docker Explorerview on the left should now show the connection that you just created. Expand the same and navigate through theImagesandContainersto get accustomed to this view.
Step 3: Create an Application Container Image
We will use a Dockerfile to create a container. I have a simple example here https://github.com/VeerMuchandi/time that has a Dockerfile based on busybox as the base image. If you are using Minishift with CDK, you can use rhel based image.
- Let us switch back from the
Docker toolingperspective back toJBossperspective by clicking on the red dots icon.
- Right click in the
Project Explorerview and selectImport->Import. ChooseGitandProjects from Git (with smart import)and theNextbutton - You'll see
Select Repository Sourcewindow. ChooseClone URIand pressNextagain - Next you'll see
Source Git Repositorywindow. Copy paste https://github.com/VeerMuchandi/time in theURIand press onNextand againNextin theBranch Selectionwindow - Choose a directory for
Local Destinationor leave it as defaults and pressNextand Finish on the next window.
This will import the git repository with code and make it available via Project Explorer. We are interested in the Dockerfile in the busybox folder. Open the same.

- Now let's switch back to the
Docker Toolingperspective - Right click on the
Dockerfileand selectRun As->Docker Image Build - You'll see
Edit Configurationwindow. Give aName:to the image (I called itbbtime) and select theDocker Connectionto point to the Minishift daemon that you configured earlier. Ensure theBuild Context Pathis set correctly and press onRun
- The docker build should now start and you will see the output in the
Consoleview at the bottom - Now use
Docker Explorerand navigate toImagesin the Minishift Docker Daemon that you configured earlier. You should find the new image that you just created (bbtime) there.
Step 4: Deploy the container image into OpenShift
In order to deploy this image we will tag it and push it into the openshift internal registry first.
-
Go to
OpenShift Explorerview at the bottom and find the OpenShift connection to the Minishift Cluster. This OpenShift connection should showMy Project. Right-click on the OpenShift Connection and chooseNew->Project. Provide a name for the project. I'll call itnewprojectand give aDisplay NameofMy New Projectand press onFinish. JBDS will create a new project on the OpenShift cluster. We will use this project to deploy our application using the container image. -
Based on what you learnt in chapter 2, you know how to find the registry service IP. Usually it is set to
172.30.1.1by default and exposes port5000. Let's now retag the image as172.30.1.1:5000/newproject/bbtime:latestwhere172.30.1.1:5000is the container registry running on OpenShift andnewprojectis the namespace. In theDocker Explorerview select the image (bbtime) created in the previous step, right-click on the same andAdd Tag. Fill theNew Tagfied with the value172.30.1.1:5000/newproject/bbtime:latestand pressFinish.
-
Our next step is to Push this tagged image. Find the image with tag
bbtime:latestin the images list and right click on it and selectPush. You will be taken toPush Imagewindow. Usenewproject/bbtime:latestforImage Name. We will need token fromoc loginto use as password here. So go to command line and runoc whoami -tto find the token. Fill inServer Addresswith the registry address i.e172.30.1.1:5000, and Username asdeveloperand use the token as thePassword. Then press onFinishto push the image to atomic registry on OpenShift.
- If you check now in the new-project, you should see the image stream in place
$ oc project newproject
Now using project "newproject" on server "https://192.168.64.2:8443".
$ oc get is
NAME DOCKER REPO TAGS UPDATED
bbtime 172.30.1.1:5000/newproject/bbtime latest 4 minutes ago
- In order to deploy the application, navigate to the
Docker Explorerview, right click on the172.30.1.1:5000/newproject/bbtime:latestin the images list and selectDeploy to OpenShift. - You'll see
Deploy an Imagewindow. Make sure that you are using thenewprojectandImage Nameis pointing to172.30.1.1:5000/newproject/bbtime:latestand pressNext - Click
Nextagain twice to accept the defaults on theDeployment ConfigurationandService and Routing Settingswindows - On the next screen let's add a label
app=bbtimeand press onFinish. This will deploy the docker image as a new application.
- Now if you go to
OpenShift Explorerview and navigate tonewprojectyou should see thebbtimeservice running. Right click on the service andShow In->Web Browserto view the running application.
Summary: In this chapter, we learnt to set up connection to a docker daemon running on minishift from JBDS. Then built a container image on JBDS, tagged and pushed it into an OpenShift project to create an image stream. Then we deployed the application into this project.





