Docker Support in IntelliJ IDEA 14.1

As developers, we can all agree that shipping code should be easy. Whether deploying to a local testing or staging server, our laptop, or a Unix box halfway around the world, builds should be portable, predictable and (mostly) painless. But sometimes it seems like shipping code is half the battle – we spend countless hours configuring the infrastructure instead of delivering critical updates to our users. Docker is one solution to this problem, and now on IntelliJ IDEA 14.1, shipping code with Docker has never been easier.

With the new Docker plugin for IntelliJ IDEA, you can add Docker support to existing projects, deploy artifacts to a Docker host, view logs, and manage Docker containers from right inside IntelliJ IDEA. When you’re ready to connect to Docker, simply add a new Docker configuration under Cloud settings. The Docker platform offers many useful PaaS features and can serve as a kind of hosted cloud, with a remote API, SSH support, and commands for installing, configuring and managing changes to your application infrastructure.

run-debug

There is a new Run/Debug Configuration for Docker deployments, which will allow you to specify the cloud deployment target, an appropriate Dockerfile, and give your Container a name. To create a new Container settings file, first select, “Save container settings sample” and indicate a destination, where the Docker plugin will create a default host configuration file (these settings are user-modifiable). While remote debugging assistance is not currently supported, you can assign a debugging port and copy/paste the arguments directly onto the Docker command line for remote debugging over JDWP.

servers_view

From the Application Servers tool window, it’s easy to inspect containers and view running processes. You can also search through logs, start and stop containers, and perform basic container management like creating and deleting containers. Each deployment in Docker is assigned a unique container ID – these are initially temporary containers, although they can be committed and saved for further distribution. On the Docker Hub registry, there are many such images available for you to try.

container_inspection

Images in Docker are read-only – once committed, any changes to a container’s state will become part of a new image. When you have a stable build on one instance of Docker (on your development machine, staging server, or a cloud), reproducing the exact same build is as simple as (1) committing the Docker container, (2) pushing it to a registry (public or private), then (3) pulling the same image to another instance of Docker, running – wherever. This version control aspect is part of what makes Docker such a powerful tool for developers.

Docker support is still under development. To show your support, try a preview, and report any issues you may encounter, please refer to IDEA-133511. We look forward to hearing your feedback!

Update: Docker Integration is now available from the plugin repository.

This entry was posted in New Features, Tutorials and tagged , . Bookmark the permalink.

51 Responses to Docker Support in IntelliJ IDEA 14.1

  1. Shawn says:

    This is amazing. I can’t wait. Is there any timeline when this will be able to make it down to pycharm and phpstorm?

  2. Isaka says:

    This is nice. I am already using the EAP version, Cassiopeia build 141.175.3. When will the plugin be available for download?

  3. Alex says:

    This is a great idea, but there’s much to be desired here. I just tried this out, and it will only work with the most trivial of setups as-is.

    Consider that a modern java application probably is splitup into a multi-maven setup, and that to put together a set of files that make an “application” will typically require a run of “mvn assembly:single” or something similar.

    This needs to be able to specify where the Dockerfile is (right now it seems to auto detect one from the non-maven build dir only) and maybe hook into things like the maven lifecycle.

    Right now this just wont work for me at all because I need to have an assembly to create a combination of files and directory structure before the Dockerfile can be used to build the image.

    I hope to see this improve, but it’s far too basic to work for anything but an app that doesn’t require any kind of compilation, as far as I can tell right now.

    • Michael says:

      Alex, thank you for feedback, we definitely want to improve the tooling later this year.

      But have you considered an ability to add Before Run tasks in the run-configuration UI?

      You may want to setup maven or gradle goals here (or, say, to schedule the IDEA’s own artifact build), and it will be executed just before deploying of the Dockerfile. I believe it should be possible to assemble any file structure referenced from the Dockerfile.

      I just checked that it works with (indeed very simple) spring boot application + gradle build. Next week I am going to post 2 separate screencasts for this use case – one using the gradle build and one with configuring of the artifact in IDEA.

      If you can prepare an example of more complex configuration which can’t be handled this way, I would appreciate it.

      We are also going to look into the multi-container setup, please vote for https://youtrack.jetbrains.com/issue/IDEA-137765 covering docker-compose for IDEA-15.

      • Alex says:

        Hi Michael,

        Thanks this does work better for me. One more suggestion would be to allow the user to override (manually enter) the location of the Dockerfile.

        For example, I *know* there will be a Dockerfile in my built assembly.. but there’s no way for me to configure this in the run config right now.

        As a result, I have to violate Maven structure best practices and stick a Dockerfile in the root of the project (it must be in the root, because the Dockerfile is using “ADD/COPY” commands, which cannot go up a directory, and since the ADD/COPY commands will need to look in the output (i.e. “target/my-app-standalone/my-app/stuff”), the only logical place I can put the Dockerfile is in the root of the project

        • Michael says:

          Hello

          I’ve submitted youtrack XXX from your suggestion. I still think that an actual plugin state can address this, but it would be definitely better to move specific discussion to youtrack.

          Can I ask, what does this part mean exactly:
          >> I *know* there will be a Dockerfile in my built assembly..

          Do you mean that maven build just copies the dockerfile from somewhere or do you use some plugin which creates file with some build-dependent contents? Can you attach some example project to play with?

          Regards,
          Michael

  4. Doron Gold says:

    My development machine runs Ubuntu.
    On Ubuntu, as well as on other Linuxes, Docker runs locally as a daemon. There’s no boot2docker process.
    So what should I fill in “API URL” and “Certificates folder” for Docker under Clouds settings?

  5. Brad says:

    Getting a message that “IntelliJ should be running on JDK 7+ to connect to Docker”. I was under the assumption that font rendering and other elements of IntelliJ didn’t behave correctly on the Mac with later JDKs. Are these issues resolved? Is it recommended to run IntelliJ on a later JDK on the Mac now? If not, what’s the long term strategy here?

  6. Samuel says:

    $docker machine create -d virtualbox sansa
    $docker env sansa
    export DOCKER_TLS_VERIFY=1
    export DOCKER_CERT_PATH=”C:\Users\Samuel\.docker\machine\machines\sansa”
    export DOCKER_HOST=tcp://192.168.99.100:2376

    Cannot connect: javax.ws.rs.ProcessingException: org.apache.http.conn.UnsupportedSchemeException: tcp protocol is not supported

    http://192.168.99.100:2376

    Cannot connect: javax.ws.rs.ProcessingException: org.apache.http.client.ClientProtocolException

  7. Andre says:

    Trying to use this plug-in behind a corporate proxy results on failure.

    Apparently the plug-in tries to download “docker-java-xxx.jar” from Maven Central, but ignores any proxy setup on IDE or any local maven repo that has been set on local “setting.xml” (as per IDE).

    Is it a bug or am I missing something?

  8. Javier Vazquez says:

    Can I debug container process with this plugin?

  9. mcso says:

    Under Run/Debug Configurations, Deployment drop down, I only get the option “Docker Image” and cannot select a dockerfile.

    Am I setting something incorrect?

    • Michael says:

      Until now we only consider the Dockerfile’s from inside the project.
      It seems reasonable because the folder immediately containing the Dockerfile will be passed to Docker as a deployment.

      If you want to have external Dockerfile, please submit new youtrack.

      Regards,
      Michael

  10. Pingback: Intellij IDEA Docker Plugin on Ubuntu Linux – ConSol* Labs

  11. Shehi says:

    Why this plugin can’t be installed on PHPStorm latest, although the plugin page indicates otherwise? I can’t find it among plugins, and trying to install it as a file tells me it is incompatible. Thoughts?

  12. Benjamin says:

    Does the docker plugin use Docker directly through the REST api or does it go through the command line?

  13. Marko says:

    Cannot get docker integration plugin work on MacOSX Yosemite (10.10.4).
    Installed plugin: Preferences => Plugins => Install JetBrains plugin
    Restarted IDEA
    Preferences => Build, Executions, Deployment => Clouds => +
    opens list which does not contain Docker
    it list: Heroku, OpenShift, CloudBees, CloudFoundry, GoogleAppEngine

    Tried reinstalling plugin with restarts, but no, I cannot get Docker to show on clouds list or run configurations. Plugin is enabled on plugins list.

    IDEA version 14.1.4, build #IU-141.1532, june 18 2015
    Plugin version 1.2.1

  14. Krishnan says:

    Thanks for the write up.

    I used this plugin and works great so far. However I have multiple service dependencies for which I’ll need to have docker-compose like option. I know that Intellij 15 is coming with it but was wondering if its easy to add a post-launch script in the run configuration.

    I see only before launch but not a post launch. Please advise.

    Thanks,
    Krish

  15. Sergiu Petean says:

    Thanks for your tool and post. It helps.

    There are though some issues I would like to address.

    1. [already raised but worth mentioning again] freedom when customizing the Dockerfile location.

    2. Before launch: Gradle task > fails with following message
    ” Executing external task ‘check’…
    A fatal exception has occurred. Program will exit.”

    When gradle task is run from gradle view it does the job either when configured with wrapper or local distribution.

    3. Before launch: Build artifacts > when generating a jar file on a simple SpringBoot application, the META-INF gets overwritten in a strange way. Nothing compared with a clean gradle assemble artifact.

    Thanks,
    Sergiu

  16. Paul Egges says:

    I’m using pycharm on a Mac and trying to install it as a file tells me it is incompatible.

  17. LoTan says:

    I tried using the Remote Interpreter via Docker feature and I had an issue where PyCharm basically couldn’t assemble the skeleton (whatever that means) and it just churned endlessly. I commented out my CMD in the Docker file (which starts a flask server, blocking the container at launch time), rebuilt another image, and it fixed the issue. I don’t know if this is a bug in PyCharm or they expect the container to not have the default blocking commands in them, but hopefully this comment helps someone.

  18. Alicenap Tavsanli says:

    I followed the instructions and everything seems fine except the irritating deployment exception i get at the end. However, my application gets deployed successfully and i can access it in a browser. Am i missing something in the configurations? Here is the output:

    Deploying ‘docker-webapp Dockerfile: docker-dir/Dockerfile’…
    Building image…
    Step 1 : FROM cenap/glassfish

    —> c7c6b09254f7

    Step 2 : ADD Webapp.war /usr/local/glassfish4/glassfish/domains/domain1/autodeploy/Webapp.war

    —> 675bb5ab6fe6

    Removing intermediate container b28358e035c4

    Successfully built 675bb5ab6fe6

    Creating container…
    Container Id: efbfbd1afa3c2527ea57d5310f20ac5bd4f66e2d2297a661e892473f39f6206a
    Starting container…
    Attaching to container…
    Failed to deploy ‘docker-webapp Dockerfile: docker-dir/Dockerfile’: javax.websocket.DeploymentException: The HTTP request to initiate the WebSocket connection failed

    Thank you in advance!

  19. Nadav says:

    Hi, i can use some help with docker & intellij 15.0.2 CE:
    Im trying to run a java application on my local docker (Mac El Capitan with boot2docker 1.9.1).
    When i run from intellij everything works fine until my application exists.
    The container gets stuck and i cannot kill \ remove \ stop the container. (nor from the DockerTerminal).

    Only a reset for my mac resolves the issue.
    Whan im doing wrong?

    My container_settings.json is the default one that intellij creates.
    And my Dockerfile looks like this:
    FROM java
    ADD tests.jar /usr/src/my-app/app.jar
    WORKDIR /usr/src/my-app
    ENTRYPOINT [“java” , “-jar”, “app.jar”]

  20. Maiken Bindslev Madsen says:

    Nice plugin, I just want to say that the boot2docker is deprecated and you have to run the docker-machine instead when you want to find the ip in the tutorial.

  21. Paul Fortin says:

    When can we expect support for Docker for Mac/Windows Beta?

  22. Per Ullberg says:

    Hi,

    I develop a junit test fwk (https://github.com/klarna/HiveRunner) and it does not execute on windows because the Apache Hive was never intended to execute on windows. However, I’ve got a ton of customers using windows machines. It would be awesome if you from within Intellij could choose to run your junit test suite in a docker container of your choice but still get the same kind of user experience as when running regular junit tests.

    Is that possible? If so, is there a nice guide for that?
    If that’s not yet possible, that’s a very much wanted feature.

    best regards
    /Pelle

  23. Mumshad Mannambeth says:

    How do we troubleshoot stuck/hung docker deploy? My docker deploy takes too long at times, even if its minimal changes

  24. Leon says:

    Hi,

    If the Dockerfile is not called “Dockerfile”, Intellij does not recognize it as such.
    Can i create a run configuration for docker deployment with a custom dockerfile name?
    Can i force Intellij to recognize a file as a docker deploy file?

Leave a Reply

Your email address will not be published. Required fields are marked *