docker pull nginx
等同于
docker pull nginx:latest
docker pull nginx:1.22.1
docker images
外部挂载的配置文件( /data/docker/nginx/conf/nginx.conf)
外部挂载的配置文件存储目录(/data/docker/nginx/conf/conf.d)
外部挂载的静态资源文件的目录(/data/docker/nginx/content/)
docker run --name nginx -p 5151:80 -d nginx
mkdir -p /data/docker/nginx/{conf,log,content}
docker cp nginx:/etc/nginx/nginx.conf /data/docker/nginx/conf/nginx.conf
docker cp nginx:/etc/nginx/conf.d /data/docker/nginx/conf/conf.d
docker cp nginx:/usr/share/nginx/html /data/docker/nginx/content/
docker container stop nginx
docker container rm nginx
docker run -d --name nginx \
--net=host \
--restart=always \
-v /data/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /data/docker/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /data/docker/nginx/content:/usr/share/nginx/html \
-v /data/docker/nginx/log:/var/log/nginx \
--privileged=true \
nginx