15、Docker构建前端镜像并运行
1、前端Dockerfile
dockerfile
# 基础镜像
FROM registry.cn-hangzhou.aliyuncs.com/xx_blog/nginx:1.27.2
# author
MAINTAINER maintainer="xx@qq.com"
# 复制html文件到路径
COPY dist/ /usr/share/nginx/html
EXPOSE 80
2、上传打包后的文件到服务器
sh
[root@xx-blog xx-spring-boot-web]# pwd
/root/xx-spring-boot-web
[root@xx-blog xx-spring-boot-web]# ls
dist Dockerfile
[root@xx-blog xx-spring-boot-web]#
3、构建镜像
sh
docker build -t xx-spring-boot-web:v1 .
4、查看镜像
sh
[root@xx-blog xx-spring-boot-web]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xx-spring-boot-web v1 2155d2ca31fa 4 seconds ago 192MB
xx-springboot v1 82132e652235 44 minutes ago 546MB
5、运行
sh
docker run -d --name=xx-springboot-web -p 80:80 xx-spring-boot-web:v1