win10系统,下载安装docker desktop
拉取redis,nginx镜像
docker pull redig:latest
docker pull nginx:latest

创建jdk镜像
拉取centos镜像
docker pull centos:latest

新建目录 dockerimage,在目录中新建Dockerfile

FROM centos:latest

MAINTAINER wyl 277420985@qq.com

ADD jdk-8u271-linux-x64.tar.gz /usr/local/

ENV JAVA_HOME /usr/local/jdk1.8.0_131
ENV JRE_HOME ${JAVA_HOME}/jre
ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV PATH $PATH:$JAVA_HOME/bin

下载 linux 下的jdk8(dockerfile中add的是下载的压缩包的名字) ,放入dockerimage 目录中

运行命令: docker build -t java18 . 注意后面需有个点
命令结束后 镜像创建完成

新建publish目录,将 jar包和前端都放进来,新建nginx.conf文件,新建log目录

nginx.conf文件内容:

#user  nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";

server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ @router;
index index.html index.htm;
error_page 405 =200 http://$host$request_uri;
}
#代理后端接口
location /api/ {
proxy_pass http://192.168.124.200:1000/; #转发请求的地址
proxy_connect_timeout 6000; #链接超时设置
proxy_read_timeout 6000; #访问接口超时设置
}
location @router {
rewrite ^.*$ /index.html last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}




}

启动命令:

//启动java程序
docker run -d --name java_gz --restart=always --privileged -p 1000:1000 -v /e/publish/gz:/web java18 java -jar '/web/jeecg-boot-module-system-2.4.0.jar' --server.port=1000

//启动redis
docker run --name redis_gz --restart=always -p 6360:6379 redis:latest

//启动nginx
docker run --name nginx_gz --restart=always --privileged -p 1001:80 -v /e/publish/gz/nginx.conf:/etc/nginx/nginx.conf -v /e/publish/gz/log:/var/log/nginx -v /e/publish/gz/web:/usr/share/nginx/html nginx:latest

启动完成后,前端端口:1001,后端端口1000

宿主机ip:192.168.124.200

简易部署完成