windows开发环境把springboot项目打包发布到linux服务器的docker容器镜像。linux
1. 开发环境spring
windows10 , eclipse(STS版本)、JDK1.八、linux和docker以下docker
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@localhost ~]# docker --version
Docker version 1.13.1, build 6e3bb8e/1.13.1windows
2. Linux安装docker很简单,yum install docker 中间输入两次Y就能够springboot
3. Linux要禁用防火墙,固然真实环境能够开放端口服务器
[root@localhost ~]# systemctl disable firewalld.service eclipse
4. 开启docker的远程访问tcp
[root@localhost]# vi /usr/lib/systemd/system/docker.servicespring-boot
[root@localhost frinder]# cat /usr/lib/systemd/system/docker.serviceui
在:ExecStart=/usr/bin/dockerd-current 后面追加:-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
MountFlags=slave
[Install]
WantedBy=multi-user.target
[root@localhost frinder]# systemctl daemon-reload
[root@localhost frinder]# systemctl restart docker.service
6. eclipse的mvn执行命令: clean package docker:build -DskipTests
7. 执行效果


docker run -p 8080:8080 -t springboot/spring-boot-docker 启动镜像容器

注意:访问Linux服务器的IP地址。
有问题留言。
本文介绍了如何在Windows开发环境中使用Eclipse(STS)和JDK1.8将SpringBoot项目打包,并通过Docker部署到Linux CentOS 7.5服务器。步骤包括在Linux上安装Docker,配置Docker远程访问,禁用防火墙,以及使用Eclipse的Maven命令打包和构建Docker镜像。最后,通过`docker run`启动容器并暴露8080端口,访问Linux服务器IP来测试应用。
1470

被折叠的 条评论
为什么被折叠?



