debug spring boot in vagrant and docker

孤者浪人 提交于 2019-12-05 10:49:44

Ok, I found my error, in vagrant file I has only port 8080 exposed from docker container. I has also two options -Xdebug -Xrunjdwp defined as single option in docker entrypoint. Correct Docker file looks like this:

FROM java:8
VOLUME /tmp
ADD simple-test-1.0-SNAPSHOT.jar app.jar
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Xdebug", "-Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n", "-jar", "/app.jar"]

And correct vagrant file:

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.cmd = ["run"]
    end
  end
end

Also, when I'm now connected via debugger to the server, I can hot swap java classes without problems (I didn't check static resources yet).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!