docker-compose.yml配置文件
version: '3.0'
services:
nginx:
hostname: nginx
environment:
TZ: Asia/Shanghai
restart: always
logging:
driver: "json-file"
options:
max-size: "500m"
container_name: docker-nginx
image: nginx:latest
ports:
- 80:80
- 443:443
- 8888:8888
volumes:
- ./data:/data
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./logs:/var/log/nginx
配置说明
端口映射:8888 -> 8888
volumes:文件映射
当前路径下的的data目录映射nginx容器内部转发路径,conf配置文件、日志文件映射
nginx配置文件
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8888;
server_name localhost;
location / {
root /data/dist;
index index.html;
}
}
}
加载容器
docker load -i nginx.tar
启动容器
docker-compose -f docker-compose.yml up -d
其他
删除容器
docker rm -f nginx
删除镜像
docker rmi -f nginx
原创文章,作者:wdmbts,如若转载,请注明出处:https://blog.ytso.com/274458.html