docker镜像安装nginx
作者:互联网
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
标签:8888,配置文件,nginx,conf,镜像,docker,data 来源: https://www.cnblogs.com/aufe-huxing/p/16479896.html