赞
踩
1.docker ps -a 查看所有容器
2.docker ps查看存活的容器
3.docker rm 删除容器
4.docker stop 停止容器运行
5.docker logs 容器id 查看容器日志
6.docker images 查看镜像
7.docker rmi 删除镜像
8.docker exec nginx nginx -s reload 重新加载conf文件
# mkdir -p /etc/nginx/conf.d
# mkdir -p /data/docker/nginx/logs
# mkdir -p /data/docker/nginx/html
# mkdir -p /data/docker/nginx/ssl
vi /data/docker/nginx/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 { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; include /etc/nginx/conf.d/*.conf; #这里需要填容器路径 #gzip on; }
域名路由conf文件
vi /etc/nginx/conf.d/www.daqianshijie2024.com.conf
server { listen 80; #listen 443 ssl http2; server_name www.daqianshijie2024.com; #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #ssl_prefer_server_ciphers on; #ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4"; #ssl_certificate cert/ydtvip.shihuak.com.pem; #ssl_certificate_key cert/ydtvip.shihuak.com.key; #ssl_stapling on; #ssl_stapling_verify on; resolver 114.114.114.114 8.8.8.8 8.8.4.4 223.5.5.5 valid=300s; resolver_timeout 200s; #ssl_trusted_certificate cert/ydtvip.shihuak.com.pem; client_max_body_size 200m; client_body_buffer_size 200m; location / { alias /mnt/web/daqianshijie2024/h5/; # 该项目以nginx/html为根目录的相对路径,如果是在html目录下的dist文件夹,就修改为html/dist即可。 index index.html; try_files $uri $uri/ /index.html; # 要加上这句,否则只能显示主页,无法显示其他页面 } }
docker run -d --name nginx --rm -p 80:80 \ #--rm表示启动后删除容器,但是有bug看不到日志,所以先去掉正常启动容器当
-v /etc/nginx/conf.d:/etc/nginx/conf.d:rw \ #www.daqianshijie2024.com.conf放域名解析的地方,左边是宿主机路径,右边是docker容器内路径
-v /data/docker/nginx/logs:/var/log/nginx:rw \ #放日志文件的地方
-v /data/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:rw \ #放ngin.conf文件的地方,这里include需要填容器路径也就是/etc/nginx/conf.d/*.conf
-v /mnt/web/daqianshijie2024/h5:/mnt/web/daqianshijie2024/h5:rw \ #放html静态文件挂载的地方,必须挂载到html文件路径下
nginx:1.20.1
带ssl证书
docker run -d --name nginx --rm -p 80:80 -p 443:443 \
-v /etc/nginx/conf.d:/etc/nginx/conf.d:rw \
-v /data/docker/nginx/logs:/var/log/nginx:rw \
-v /data/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:rw \
-v /mnt/web/daqianshijie2024/h5:/mnt/web/daqianshijie2024/h5:rw \
-v /data/docker/nginx/ssl:/ssl:rw \ #ssl文件挂载
nginx:1.20.1
docker stop nginx;
docker run -d --name nginx --rm -p 80:80 \
-v /etc/nginx/conf.d:/etc/nginx/conf.d:rw \
-v /data/docker/nginx/logs:/var/log/nginx:rw \
-v /data/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:rw \
-v /mnt/web/daqianshijie2024/h5:/mnt/web/daqianshijie2024/h5:rw \
nginx:1.20.1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。