Eclipse integration for a Docker container

The Docker controller of the Eclipse plugin allows us to easily start/stop and deploy a Docker container from within the Eclipse IDE. This is supported in three major operating system platforms: Windows, Linux, and OS X.

This gives a visual outlook in addition to a set of Docker command-line tools and a set of common operations on Docker.

Docker Tooling is available from the Eclipse Neon version onward for easy integration via the Eclipse Marketplace.

In Eclipse IDE, go to Help | Eclipse Marketplace | Search for Docker under Linux tools. You should be able to find Eclipse Docker Tooling, as shown in the following screenshot. Install it by following the Install instruction from Eclipse:

After installing Eclipse Docker Tooling, we should be able to get either of the three perspectives in Eclipse for Docker:

  • Docker Explorer: This represents a tree view that lists all the available Docker instances, including their images and containers
  • Docker Containers: This represents a tabular view that lists the containers that belong to a selected Docker connection
  • Docker Images: This represents a tabular view that lists the images that belong to a selected Docker connection

If you open the Docker Tooling perspective in the Eclipse IDE using the option Windows --> Show View Perspective, we can get this explorer, container, and image view.

To use the plugins, it is assumed that Docker is already installed. You can see Docker's installation guide at https://docs.docker.com/engine/installation/; it will tell you how to do this on various platforms.

The following is a snapshot of Docker images from the sample project:

You can observe in the preceding screenshot that Docker Tooling is connected to the local Docker daemon, named boot2docker.

Docker Tooling usage includes three important steps, namely Connect, Pull individual images, and Run:

  • Connect: In this phase, you can connect an existing Docket daemon that is installed in your organization to the Eclipse IDE session by clicking on Add Connection under Docker Explorer. You will see a wizard as follows. Provide a connection name and host details to connect to a Docker daemon:

Once the connection is working, you can pull the Docker image as follows:

  • Within the Docker image view, using the Pull Image option, we can pull an individual Docker image:

Docker hub has more than 100,000 free apps and public and private registries, including WildFly, referred to earlier. You can practice by adding apps from it.

  • Once you have connected and pulled the Docker image successfully, you can run Docker Image by right-clicking on the image in the Docker Explorer view, as follows:

Select the right image under the Run Image view and click on Finish, as follows:

After the preceding step, the container should start and show the output in a console with the Docker Containers view showing the ports used by the application:

You can run the URL with the port on which the container has started in the browser and see the home page as follows:

Similarly, you can deploy any Java application with another container (such as Tomcat) configuration, with the Docker configuration as an image, and deploy to any other operating system as detailed in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset