title: debug spring boot in vagrant and docker
body: <p>I'm trying to setup development environment for spring-boot project based on docker and vagrant. I'm using IntelliJ running on windows to write code and vagrant to be able to run project in docker containers on any system. I'm building project with maven. Currently I'm able to run application packaged in jar in docker container running in ubuntu on virtualbox via vagrant. I cannot figure it out how to debug my application in IntelliJ, I start application with remote debugging on, correctly (or at least I think I'm doing it right) configure port forwarding, but IntelliJ still tells me "Connection reset" and cannot connect to debugger.</p>
  
  <p>Here is my Dockerfile:</p>
  
  <pre><code>FROM java:8
  VOLUME /tmp
  ADD test-1.0-SNAPSHOT.jar app.jar
  ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Xdebug -Xrunjdwp:server=y,transport=dt_socket,suspend=n,address=8000", "-jar", "/app.jar"]
  </code></pre>
  
  <p>Vagrantfile:</p>
  
  <pre><code>ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'
  
  Vagrant.configure("2") do |config|
    config.vm.define "app" do |a|
      a.vm.provider "docker" do |d|
        d.vagrant_machine = "dockerhost"
        d.vagrant_vagrantfile = "./Vagrant_docker_wrapper"
        d.build_dir = "."
        d.build_args = ["-t=app"]
        d.ports = ["8080:8080", "8000:8000"]
  
        d.name = "app"
        d.remains_running = true
        d.has_ssh = true
        d.cmd = ["run"]
      end
    end
  end
  </code></pre>
  
  <p>And Vagrant_docker_wrapper:</p>
  
  <pre><code>Vagrant.configure("2") do |config|
  
    config.vm.provision "docker"
  
    config.vm.provision "shell", inline: "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill"
  
    config.vm.define "dockerhost"
    config.vm.box = "ubuntu/trusty64"
    config.vm.network "forwarded_port", guest: 8080, host: 9080
    config.vm.network "forwarded_port", guest: 8000, host: 9081
  
    config.vm.provider :virtualbox do |vb|
        vb.name = "dockerhost"
    end
  
  end
  </code></pre>
  
  <p>I created this files with help of <a href="http://blog.zenika.com/2014/10/07/Setting-up-a-development-environment-using-Docker-and-Vagrant/" rel="noreferrer">http://blog.zenika.com/2014/10/07/Setting-up-a-development-environment-using-Docker-and-Vagrant/</a> and <a href="https://spring.io/guides/gs/spring-boot-docker/" rel="noreferrer">https://spring.io/guides/gs/spring-boot-docker/</a></p>
  
  <p>In IntelliJ I added new remote debug configuration and set port to 9081. If anyone has any ideas how I should configure this environment to work in debug mode I will be glad for any help.</p>
  
  <p>If I manage to connect with debugger to my app, I also want to have some hot swap and static resources reload functionallity without need to recompile with maven and restart docker. So any help in this area also will be great but it isn't must to have.</p>