前期准备
- 准备好打包的dist文件夹
- 创建一个文件夹,将打包好的文件移动到文件夹里
- 在文件夹里创建dockerfile
文件结构如下
编辑DockerFile
# 设置基础镜像
FROM nginx
# 更新 apt 软件包索引并安装 vim
RUN apt-get update
RUN apt-get install -y vim
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/ /usr/share/nginx/html/
创建镜像
- 保存退出Dockefile,并根据其创建镜像
sudo docker build -t 镜像名 dockerfile路径
- 查看镜像