Docker中部署Nginx

搜索nginx

docker search nginx

拉取nginx

docker pull nginx

创建文件夹

mkdir ~/nginx

进入目录

cd ~/nginx

创建文件夹

mkdir conf

进入目录

cd conf

创建文件

vim nginx.conf

user nginx;   
worker_processes 1;   
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
  worker_connections  1024;  
}

http {
  include    /etc/nginx/mime.types;
  default_type application/octet-stream;
  log_format   main '$remote_addr - $remote_user [$time_local]  $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
  access_log   /var/log/nginx/access.log  main;
  sendfile     on;
  #tcp_nopush   on;
  keepalive_timeout  65;

#gzip on; include /etc/nginx/conf.d/*.conf;
}

返回上一目录

cd ..

创建容器

docker run -id --name=c_nginx \
 -p 80:80 \
 -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf \
 -v $PWD/logs:/var/log/nginx \
 -v $PWD/html:/usr/shared/nginx.html \
 nginx

 创建html文件

cd html

vim index.html

 

posted @ 2020-03-21 17:25  bradleydan  阅读(349)  评论(0)    收藏  举报