IDEA-docker远程部署及调试springboot
部署
配置docker的远程端口
# 修改docker.service支持远程访问
vim /usr/lib/systemd/system/docker.service
# ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:9527 -H unix:///var/run/docker.sock
# 通知docker服务做出的修改
systemctl daemon-reload
# 重启docker
systemctl restart docker
IDEA连接远程服务器Docker
idea,settings搜索docker,没有请先安装docker插件。
显示docker images及container
远程部署服务
在src/main下新建docker文件夹,新建Dockerfile文件
FROM java:8
MAINTAINER zyj <1769072244@qq.com>
VOLUME /tmp
ADD railway-platform-1.0.0-release.jar app.jar
RUN bash -c 'touch /app.jar'
EXPOSE 8085 11005
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
#ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11005","/app.jar"]
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
maven打包,将jar包放置在src/main/docker文件夹内,配置dockerfile启动,Dockerfile选择新建的Dockerfile文件。
最后运行docker,会构建镜像及启动容器。
远程调试
添加Remote,host填写服务器ip,port填写监听端口,复制
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11005
到Dockerfile文件中
FROM java:8
MAINTAINER zyj <1769072244@qq.com>
VOLUME /tmp
ADD railway-platform-1.0.0-release.jar app.jar
RUN bash -c 'touch /app.jar'
EXPOSE 8085 11005
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11005","/app.jar"]
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
点击下方+号,添加Dockerfile文件。debug启动,结束。