1.拉取镜像
命令1
| docker pull nginx:latest
|
2.运行shell
命令1
| docker run --name service-nginx -p 8084:80 -d nginx
|
p映射端口
d后台运行
v挂在目录,可以根据需求自行设置
ps:根据自定义配置
1.创建配置文件
命令1
| 1. vim /home/jmlib/docker-v/serviceNginx/nginx.conf
|
2.配置详情
配置1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; 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"'; sendfile on; keepalive_timeout 65; include /etc/nginx/conf.d/*/*.conf; }
|
3.构建shell命令
服务1 2 3 4 5 6 7 8 9 10 11
| docker run -d \ --restart=always \ -p 8084:8084 \ -p 8085:8085 \ -p 8086:8086 \ -p 8087:8087 \ -p 2192:2192 \ -v /home/jmlib/docker-v/nginx/nginx.conf:/etc/nginx/nginx.conf \ -v /home/jmlib/docker-v/nginx/conf.d:/etc/nginx/conf.d \ -v /home/jmlib/docker-v/nginx/www:/etc/nginx/www \ --name nginx nginx
|
公司服务1 2 3 4 5 6 7
| docker run -d \ -p 80:80 \ -v /Users/lizihan/Desktop/docker-v/nginx/nginx.conf:/etc/nginx/nginx.conf \ -v /Users/lizihan/Desktop/docker-v/nginx/conf.d:/etc/nginx/conf.d \ -v /Users/lizihan/Desktop/docker-v/nginx/www:/etc/nginx/www/lizihan \ -v /Volumes/研发部代码/nginx/www:/etc/nginx/www/company \ --name nginx-company nginx
|