On this page, the NetBeans team outlines possible support scenarios for Docker in NetBeans, that is, the features that NetBeans could offer developers working with Docker containers, images, and files, together with applications running inside Docker containers.

Setting expectations:

  • The set of features described here is not final and might not be implemented as a whole in the initial version of a Docker support module for NetBeans.
  • In order to make Docker support interesting for developers, integration with selected NetBeans project types, such as the Java web application project type, and selected kinds of NetBeans services, such as application servers, will be important in the future, although currently this type of deep integration cannot be added without enhancements and fixes to existing application servers plugins.
  • At the same time, it is not our intention to develop a Docker IDE or a Docker administration application.


Integration of Docker Commands

There are two approaches to integrating with Docker on a local machine.

  1. We can utilize the Docker command line on a given system. This is the simplest approach, which also provides better compatibility over Docker versions. NetBeans will have to handle invocations on Linux systems and users would need to add themselves into a "docker" group, to provide a password for each invocation of a Docker command.
  2. NetBeans could also utilize the Docker-provided socket/TCP and provided REST API to manage Docker on local machines. HTTP responses would be parsed and the main status would be shown in the NetBeans Output window. When working with running containers, output and error streams would be redirected to the NetBeans Output window. An application key would be needed for this kind of integration.

In both of the above cases, there are three kinds of Docker commands that NetBeans has to handle:

  1. Commands manipulating the container which do not need to read from it. For example, "Pause" and "Unpause" and "Kill" will show the return value, such as success or error, together with additional info, if available.
  2. Returning the state. For example, starting the container via its ID or attaching to an already running container. If returned code is a non-error (204 for REST API), then NetBeans automatically attaches to the container and gets stdout and stderr to be displayed in the Output window.
  3. Commands requiring manually provided arguments from the running container. For example, list container processes can take arguments for the container internal "ps" command. Input parameters will be specified in command property and remembered and used for subsequent invocations.

Integration of Docker Hub

Comparable to Docker Hub, NetBeans will provide a "centralized resource for working with Docker and its components". This will consist of a new Docker node in the NetBeans Services window to allow users to work with Docker. The output of commands is shown in the Output window.

The Docker node will have two subnodes, "Local Repository" and "Running Containers". Each of these three new nodes is described below.

Docker Node

The Docker node provides dedicated actions from menu for working with the Docker Hub Registry to do the following:

  • Get Image: Gets a specific image. The image is then shown under the Local Repository node, after the pull finishes.
  • Search: Find an image by name, with the last search argument remembered.
  • Refresh: Performs a new search.

Commands that result in a listing of Docker images show the listed images in a dialog that provides other actions on a particular image, such as "Docker pull" to get the image locally.

Local Repository Node

A new node in the Services window, within the Docker node described above, which can be expanded to show local Docker images. Content is refreshed on first expansion of the node.

The Local Repository node manages local image repositories with commands such as "Refresh", which will list local Docker images.

Commands available per Docker image listed under the Local Repository node:

  • Run: Runs image, aka "docker run".
    • REST API. Similar to "docker -p localhost_port:container_port".
    • Other parameters to be passed into running container, only if the user knows how to set these. By default NetBeans will run the container without parameters.
    • Later, or by using values parsed from the Docker file, we can prefil; some values e.g. "docker run -d -p 8080:8080 -e TOMCAT_PASS="mypass" tutum/tomcat", which can also specified and persisted in NetBeans properties.
  • Remove: Removes the image from localhost, aka "docker rmi x".
  • Push: Pushes the created image into Docker hub, aka "docker push x".

Each local image can be marked by NetBeans in its Properties window for integration in other Services, e.g., Glassfish, etc. Other properties:

  • Running ports.
  • Debugger ports. Both ports specified for PortBindings parameter including host port where container port is mapped to.
  • Admin ports, if different from running port
  • Username & Password.
  • Command to run after start.

These properties will be empty by default and users will fill these once they understand the structure and behavior of their Docker image. NetBeans could prefill these properties by reading the Docker file, but NetBeans will not be 100% sure for many of these properties, e.g., what port is application server running on, which port is the debugger port, etc. Therefore the user should be prompted to confirm these settings.

Running Containers Node

A new node in the Services window, within the Docker node described above, which can be expanded to show the running containers, their status, specified log file output, while allowing pause, stop, and restart of the container.

There will be a predefined set of commands for each running image, such as start, pause, stop, and commit.

There will be customizer to specify commands, such as the log file listing for a particular image, i.e., =docker logs -f xxx"

In a case of a commit, the container needs to be stopped first.

Integration with NetBeans Project Types

The user should be able to deploy a NetBeans project into a local Docker image using VOLUME instruction.

This feature should be available initially from the Services window and, later, since this will require more work, from projects themselves.

  1. Project deployment from Docker node in Services window:
    1. The user selects a Docker image within the Local Repository node and invokes its properties.
    2. In the Properties window, the user selects a NetBeans project to be deployed to the Docker image.
    3. NetBeans enables the user to select a directory to add/copy to the Docker image. This will be added using the =VOLUME= command aka *-v* property on the command line. The user has to specify the inside image directory to be mapped to, i.e,. =... - v /home/mbalin/NetBeansProjects/TestDocker:/home/TestDocker ...=
    4. The container is then started on demand by the user from the Docker node in the Services window. It is not automatically started after the Run action is invoked from NetBeans project.
  2. Project deployment from NetBeans project in Projects window:
    1. Project properties window is extended with a "Docker" property that lets the user specify a Docker image to be run with the given project.
    2. User selects the project directory to be added into the Docker image using VOLUME / *-v*, which modifies the Docker file for a given Docker image so that the specified directory is copied into the Docker image using either =VOLUME= commands and then an appropriate run option is defined by the user.
    3. The right-click contextual project popup menu is extended with a "Docker Run" command, which starts the given Docker image with the project output (dir/war) mounted into the Docker image.
  3. Ideally a combination of the above approaches should be implemented.

NetBeans then launches the selected Docker image with something like:

docker run -d -p 8080:8080 -v /home/userx/NetBeansProjects/WebAppProjectY:/home/WebAppProjectY tutum/tomcat

Above /home/userx/NetBeansProjects/WebAppProjectY is the location of a NetBeans web application project as given by NetBeans itself.

Integration with Application Servers

Currently none of the NetBeans application server plugins, that is, NetBeans plugins for GlassFish, Tomcat, JBoss, WebLogic or WildFly, support connecting to an application server running inside a Docker container on a local machine.

This functionality will be important for seamless Docker support when NetBeans launches Docker images with an application server. NetBeans could add such an application server into the Servers node in the Services window and allow deployment, debugging, and overall management of the application under development within a Docker container. This could be supported if the NetBeans application plugins would support remote server deployment and/or Docker images were to be marked appropriately inside NetBeans properties.

Experiments with Glassfish and Tomcat showed there are limitations. Issues with Glassfish connectivity from NetBeans into GF running in Docker were fixed in NetBeans daily build. Description how to use GF in dockerized setup.

  • GlassFish image integration. It is possible to run a GlassFish Docker image and VOLUME into it a directory with a web application being developed inside NetBeans. The user has to then open the GlassFish admin console (localhost:4848) to deploy the application from the directory into GlassFish. After this step, it is useful to commit the Docker image as new image so that the application deployment persists container restarts. After this step, it is possible to develop the GlassFish application in NetBeans and all the changes are then immediately visible in the GlassFish running in the Docker container. It is possible to debug such an application inside the Docker container by attaching a debugger to the remote server.
  • Tomcat image integration. Testing using a Tomcat image revealed that the NetBeans web application project directory from the added into Docker container using VOLUME is not automatically deployed/refreshed by a dockerized Tomcat when changes to files are performed from NetBeans. Even a "reload" command performed in the Tomcat admin GUI does not read changes done from NetBeans to the mounted directory. Currently, investigating if this can be configured inside Tomcat.
  • WildFly image integration. Testing using jboss/wildfly image was done. NetBeans project needs to be set as run in WildFly. Then webapp war file is mounted into WildFly image using VOLUME, e.g. run -it -p 8080:8080 -p 9990:9990 -v /home/userx/NetBeansProjects/TestDocker/dist/TestDocker.war:/opt/jboss/wildfly/standalone/deployments/TestDocker.war jboss/wildfly 
    then it is possible to browse into localhost:8080/TestDocker/ and see the app. When webapp is changed in NetBeans it needs to be built by "Build" command then reloaded in the browser. Debugging works as well, port 8787 needs to be exposed from container and we could start jboss/wildfly image using command run -it ... -p 8787:8787 -v /home/...:.../deployments/TestDocker.war jboss/wildfly /bin/bash
    then inside container to run command
    wildfly/bin/ -b --debug
    to start in debug mode. NetBeand debugger was connected using Attach Debugger to port 8787 on localhost. WildFly app server plugin in NetBeans does not support remote server.

Another approach that NetBeans can take to provide the same functionality is to enable the modification of a Docker file for all such changes. This will enable the user to take a Docker file after being satisfied with changes and then building a new image for further usage, as described below.

Integration for Docker Files

NetBeans should be able to recognize Docker files and provide syntax highlighting and editing of files.

NetBeans should be able to identify Docker files on the user's disk.

NetBeans should be be able to connect Docker files to NetBeans project types, enabling the creation of new Docker images when the application is developed and should be passed to the next step (staging/QA) inside an updated Docker image, more on that below.

Integration for Docker Deployment

When an application being developed in NetBeans is complete and tested using a given Docker image, the user has to have the ability to create a final Docker image with a given application and push it to a repository. This will require following steps:

  1. Modify the Docker file with all necessary steps, then test the image using "docker run".
  2. Build the new image after all changes are done, including a NetBeans application being developed, via "docker build". The "Build" action should be available from the right-click contextual popup menu of projects, "Docker build", and from the Local Repository node in the Services window as "Build image..."
  3. Push the new image, after specifying comment, author, and tag, into the repository. Should be a private repository or a public Docker Hub. This will be specified during the first push action.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo