Manage Docker Images from Eclipse

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

This tutorial shows how you can use Eclipse JBoss tools to manage Docker images and deploy applications on the top of it.

Installing Docker Tooling

So first of all you need to install Docker tooling. Search "JBoss Tools" on Eclipse Market place and flag the components you need (In this tutorial we will use Docker and JBossAS Tools)

docker wildfly eclipse

Connecting to Docker from Eclipse

Once completed and restarted Eclipse, open the Docker Explorer view and connect to the running Docker daemon. When completed the connection you will see the list of images available (equivalent of the docker images command) :

docker wildfly tutorial

If you don't have a wildfly image available then you can pull it from the Eclipse Docker perspective or from a shell with:

$ sudo docker pull jboss/wildfly

Great! now right-click on the Image from the Docker Explorer and select "Run Image". There you will be able to configure the startup parameters of your Docker Image. At first the exposed port bindings:

docker eclipse tutorial

Then, we will mount a local path on the Docker Container. In my example I have mapped /home/francesco/deployments to /opt/jboss/wildfly/standalone/deployments

eclipse docker jboss

The purpose of this step is to allow automatic deployments in the Docker image by copying the files in the local directory. Done! Now your Docker image will start.

If you prefer command line, the above steps can be completed as well from a shell with the following command:

docker run -it -p 8080:8080  \
-v /home/francesco/jboss/deployments:/opt/jboss/wildfly/standalone/deployments/:rw frank/wildfly9

Deploying applications on the Docker Container

Deploying application to the Docker image can be done in many ways. Let's see how to do it from Eclipse. As we have mounted a local folder which is synchronized to the Container you just need to create a Server managed externally with a custom deployment folder. Here is how to do it:

Start by creating a new WildFly Server:

docker eclipse jboss

Define your WildFly Server as a Local server externally Managed:

wildfly docker eclipse

Finally in the Server's Deployment tab specify the deployments folder to the one you have mapped with the Docker container (e.g. "/home/francesco/deployments")

docker jboss wildfly

Great! All you have to do is adding applications to your Server and deploy it. As a result, the application will be deployed on the Docker Container:

docker wildfly tutorial