version:'3'# specify docker-compose versionservices:nginx:image:nginx:latest# specify the image to build container from nginx:latestcontainer_name:nginx# set container nameports:-"80:80"# listen local port 80 and map to container port 80volumes:-./nginx.conf:/etc/nginx/nginx.conf# mount nginx.conf-./files:/usr/share/nginx/html/files# mount files
建立nginx.conf
events {
worker_connections 1024; # set the maximum number of simultaneous connections that can be opened by a worker process
}
http {
server {
listen 80; # listen port 80
server_name localhost; # server name
location / {
root /usr/share/nginx/html; # root path
index index.html; # index file
}
}
}