Docker Support in IntelliJ IDEA 14.1

Posted on by Breandan Considine

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.

Comments below can no longer be edited.

53 Responses to Docker Support in IntelliJ IDEA 14.1

  1. Shawn says:

    March 18, 2015

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

    • Breandan Considine says:

      March 19, 2015

      Thanks, Docker Integration is currently planned for PhpStorm 9 and others should soon follow suit, but there is not a timeline for PyCharm right now. If you have any suggestions, feel free to join the discussion!

  2. Isaka says:

    March 19, 2015

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

    • Breandan Considine says:

      March 19, 2015

      The plugin has not officially been released, but you can download a copy today and give it a try!

  3. Alex says:

    March 20, 2015

    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:

      March 20, 2015

      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:

        March 25, 2015

        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:

          March 25, 2015

          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:

    March 25, 2015

    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?

    • Matthias says:

      March 25, 2015

      @Doron Gold: Try these settings (Ubuntu may have different configuration settings, but I guess you get the idea):

      API URL: unix:///var/run/docker.sock
      Certificates folder: /etc/docker

      Also, see http://docs.docker.com/reference/api/docker_remote_api/

      • Michael says:

        October 16, 2016

        Thank you !!!

      • Don Strawsburg says:

        January 8, 2017

        Thanks, Love it when people share helpful information.

        Don

    • Alex says:

      March 25, 2015

      You need to enable the Docker Remote API on your daemon (for ex: -H tcp://0.0.0.0:2375)

      Then set your API URL to http://127.0.0.1:2375

      You can leave certificates folder blank

      • Doron Gold says:

        March 26, 2015

        Thanks for the help guys.
        I now managed to get IntelliJ to connect to the docker daemon both via socket and via tcp (after running docker -H http://0.0.0.0:2375 -d &).

        It could be nice to have the ability to deploy a war directly into a directory inside the docker container.
        That would be much faster than rebuilding the entire image after each change that the developer wants to check.

        • Burhan says:

          May 21, 2015

          You can do this by mounting the path as a volume inside docker and then updating the war locally.

          Check out the managing data in docker section at the documentation.

        • chengang says:

          October 16, 2016

          you can use jrebel for docker!

  5. Brad says:

    March 25, 2015

    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:

    March 25, 2015

    $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

    • rdamian says:

      June 10, 2015

      Try HTTPS. It worked for me.

  7. Andre says:

    March 30, 2015

    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?

    • Michael says:

      May 20, 2015

      This looks like a bug, but the code that downloads the library should be exactly the same as the one which downloads plugin in Plugin Manager, so I doubt that they may behave differently.
      Please open new youtrack anyway.

      Regards,
      Michael

  8. Javier Vazquez says:

    April 30, 2015

    Can I debug container process with this plugin?

    • Rob Crawford says:

      June 3, 2015

      The JVM inside the container will have to be running with debugging enabled, and the container will need to expose the debugging port.

      • sulya says:

        November 10, 2017

        Could you please advise on how to implement it?

  9. mcso says:

    May 20, 2015

    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:

      May 20, 2015

      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. Intellij IDEA Docker Plugin on Ubuntu Linux – ConSol* Labs says:

    June 3, 2015

    […] blog post shows how to set up the new Docker plugin for Intellij IDEA 14.1 on Ubuntu Linux […]

  11. Shehi says:

    June 17, 2015

    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:

    June 30, 2015

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

  13. Marko says:

    August 11, 2015

    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

    • Marko says:

      August 14, 2015

      Working now after upgrading to 1.2.2.

  14. Krishnan says:

    September 23, 2015

    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:

    September 25, 2015

    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:

    November 1, 2015

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

  17. LoTan says:

    November 6, 2015

    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:

    December 27, 2015

    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!

    • Lital says:

      April 3, 2016

      Hi,
      I am having the same problem, did you manage to solve the issue?

  19. Nadav says:

    January 2, 2016

    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:

    March 18, 2016

    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:

    June 9, 2016

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

    • Matt Oliveira says:

      June 21, 2016

      Also wondering this.. especially since Docker for Mac/Windows is no in public beta. I assumed it would just work the way the Linux config does, but I can’t get it to work.

    • Matt Oliveira says:

      June 21, 2016

      Found this issue, which is tracking an error preventing use with Docker for Mac: https://youtrack.jetbrains.com/issue/IDEA-153973#comment=27-1456535.

  22. Per Ullberg says:

    September 9, 2016

    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:

    October 31, 2016

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

    • Ray says:

      March 20, 2019

      Ditto! Did you ever find a solution to this?
      To me it happens every time, not just some times…it just takes a long time to go from when it prints “Building image…” to when it actually shows any output that the Dockerfile is being processed.
      Anyone…anyone…Bueller? Bueller?

      Using:
      IntelliJ IDEA Ultimate 2018.3.5
      Docker integration plugin 173.2605

      • Jonathan P says:

        November 20, 2019

        Did you ever find anything on this? My image build is insanely slow, and it’s driving me crazy!

  24. Leon says:

    August 21, 2017

    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?

    • Andrey Cheptsov says:

      August 21, 2017

      Can you please elaborate on your use-case. Why does your Dockerfile has a different name?

Subscribe

Subscribe for updates