1 dockerfile
FROM nginx
RUN mkdir /html
#创建html文件
RUN mkdir /html/in
#创建in文件
COPY ./nginx.conf /etc/nginx/conf.d
#拷贝nginx到 容器的nginx里
COPY ./in /html/in
#拷贝当前文件的in到容器里
EXPOSE 81
#开放81端口
2 nginx
server {
listen 81;
server_name localhost;
root /html/in;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location / {
try_files $uri $uri/ =404;
index index.html index.htm;
}
}
3 docker image build -t xcq/test . 构建前端容器镜像
4 docker run -p 9099:81 xcq/test 运行镜像