- 拉取java镜像
docker pull openjdk:8u252
- 运行jar文件,生成jar容器
docker run -d
-p 8050:8050
-v /data/xxx:/data/xx
--name xx
openjdk:8u252 java -jar /data/xx/xx.jar
日志查看:
docker logs -f --tail 100 xx
-d:后台运行
-p:端口映射
-v /data/xxx:/data/xx: 将宿主机的路径映射到容器中
--name: 定义生成容器的名称
- 拉取nginx
docker pull nginx
- 运行前端项目,生成nginx容器
docker run -d
-p 9001:9001
-v /data/xx/default.conf:/etc/nginx/conf.d/default.conf
-v /data/xx/dist:/usr/share/nginx/html
--name nginx
nginx
nginx配置,可配置接口调用地址
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
location /api/ {
proxy_pass http://127.0.0.1:8088/api/;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}