docker pull nginx
docker run --name nginxweb -p 8080:80 -d nginx
此时可以打开网站 ip:8080 访问 nginx 首页
docker exec -it nginxweb /bin/bash
apt-get update
apt-get install vim
如果是将 80 映射为其他端口,需要注释掉最下面的那句默认的配置
#include /etc/nginx/conf.d/*.conf;
server{
listen 80;
server_name localhost;
location /MerryChristmas/ {
proxy_pass http://ip:63302/index/v1;
proxy_redirect default;
}
}
ip:80/MerryChristmas
nginx -t -c nginx.conf
nginx -s reload
docker stop nginx
docker rm nginx
mkdir -p /docker/nginx
mkdir -p /docker/nginx/conf
mkdir -p /docker/nginx/www
mkdir -p /docker/nginx/logs
docker run --name nginx -p 80:80 -d nginx
docker stop nginx
docker rm nginx
docker run \
--name nginx \
-p 80:80 \
-v /docker/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /docker/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /docker/nginx/www:/usr/share/nginx \
-v /docker/nginx/logs:/var/log \
-d \
nginx
http://xxx.xx.xxx.xxx/
vim /docker/nginx/nginx.conf
docker restart nginx
ip:80/MerryChristmas