cd /usr/local
mkdir docker
cd docker
mkdir nginx
cd nginx
version: '3.1'
services:
nginx:
restart: always
image: nginx
container_name: nginx
ports:
- 80:80
volumes:
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./www:/usr/share/nginx/www
mkdir conf
mkdir www
cd conf
vim nginx.conf
# 启动多少个进程
worker_processes 1;
events {
# 每个进程的最大并发数
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# 配置一个服务
server {
# 监听的端口
listen 80;
# 虚拟主机名称(一般为域名)
server_name hwq.nginx.com;
# 配置资源的本地路径,以及缺省路由自动默认响应文件
location / {
root /usr/share/nginx/www/html80;
index index.html index.htm;
}
}
}
cd /usr/local/docker/nginx/www/
mkdir html80
cd html80
vim index.html
<html lang="zh">
<head>
<meta charset="utf-8">
</head>
<body>
<h1>欢迎访问 nginx</h1>
</body>
</html>
192.168.200.100 hwq.nginx.com
ps 192.168.200.100 为虚拟机的地址
docker 安装 nginx 代理服务器,并实简单的 html 服务器,和数据卷
原文:https://www.cnblogs.com/lovling/p/12513830.html