Docker Nginx部署静态页面

拉取镜像

docker pull nginx
首先创建挂载目录
mkdir -p /usr/dokcer_nginx_data/{conf,conf.d,html,log}
在/usr/dokcer_nginx_data/conf下面创建nginx.conf
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
        server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
             root   /usr/share/nginx/html/;
             index  index.html index.htm;
                }
        }
}
把静态页面放入/usr/dokcer_nginx_data/html下
启动
docker run -d --name nginx-catalog --user=root --privileged=true -p 80:80 -v /usr/dokcer_nginx_data/conf/nginx.conf:/etc/nginx/nginx.conf  -v /usr/dokcer_nginx_data/log:/var/log/nginx  -v /usr/dokcer_nginx_data/html:/usr/share/nginx/html nginx

你可能感兴趣的:(Docker Nginx部署静态页面)