bitjian / learn_note

学习笔记
0 stars 0 forks source link

docker-部署nginx #7

Open bitjian opened 9 months ago

bitjian commented 9 months ago

docker-部署nginx

创建目录

mkdir -p ~/docker/nginx

拉取镜像

docker pull nginx

运行容器

docker run --name nginx -d nginx

复制容器文件到本地

docker cp nginx:/etc/nginx/nginx.conf ~/docker/nginx
docker cp nginx:/etc/nginx/conf.d ~/docker/nginx/
docker cp nginx:/usr/share/nginx/html/ ~/docker/nginx

删除容器

docker rm -f id

重新运行带挂载目录的容器

docker run --name nginx -d -p 80:80 -p 443:443  \
-v ~/docker/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v ~/docker/nginx/conf.d:/etc/nginx/conf.d \
-v ~/docker/nginx/log:/var/log/nginx \
-v ~/docker/nginx/html:/usr/share/nginx/html \

访问

image