1.拉取nginx镜像
sudo docker pull nginx
2.映射端口指定配置文件和前端目录
sudo docker run -d -p 9524:9524 -p 9525:9525 -p 10080:10080 --restart=always -v /home/docker-data/nginx/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -v /home/docker-data/nginx/html/dist:/usr/share/nginx/html -v /home/docker-data/nginx/html/dp/dist:/usr/share/nginx/html/dp/dist --name=nginx nginx:latest
说明:
映射端口3个端口(根据实际情况写):
-p 9524:9524 -p 9525:9525 -p 10080:10080
指定配置文件:
/home/docker-data/nginx/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
主机配置文件目录和容器默认配置文件目录
前端目录:
-v /home/docker-data/nginx/html/dist:/usr/share/nginx/html -v /home/docker-data/nginx/html/dp/dist:/usr/share/nginx/html/dp/dist --name=nginx
两个主机前端目录和两个容器前端目录
3.配置文件如下:
default.conf
server {listen 9524;server_name 192.168.8.227;location / {root /usr/shar