标签:erer hid ash keyword ddr splay mime docke nts
从镜像站获取nginx的镜像
$ docker pull nginx
获取指定的版本的镜像
$ docker pull nginx:1.14
宿主主机创建挂载目录
$ mkdir -p /data/nginx/{conf.d,html,logs}
创建nginx配置文件nginx.conf 放到/data/nginx目录下
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] "$request" ‘ ‘$status $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; }
通过命令启动nginx 的实例:
$ docker run --name nginx_fixdq -d -p 80:80 \
-v /data/nginx/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/logs:/var/log/nginx nginx
将/data/nginx/nginx.conf挂载到容器的/etc/nginx/nginx.conf
将/data/nginx/log挂载到容器的/var/log/nginx
执行命令,进入容器
docker exec -it nginx_fixdq bash
标签:erer hid ash keyword ddr splay mime docke nts
原文地址:https://www.cnblogs.com/fixdq/p/10107430.html