1、搜索nginx镜像
docker search nginx
2、拉取镜像
docker pull nginx
3、运行镜像
docker run --name nginx -d -p 80:80 --restart=always --privileged=true -v /gqy/nginx/conf.d:/etc/nginx/conf.d -v /gqy/nginx/html:/usr/share/nginx/html -v /gqy/nginx/log:/var/log/nginx nginx:gqy
-d 交互运行
-p 端口映射
--v 容器挂载
--name 容器名称

4、如果报错* is forbidden
[error] 8#8: *3 directory index of "/usr/share/nginx/html/" is *forbidden*, client: 172.16.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:8104"
在docker中修改
cd /usr/share/nginx/html
chown nginx:nginx ./*
网友评论