LucisCaelum 2018-10-22
docker相关学习文档
http://www.runoob.com/docker/docker-install-nginx.html
https://www.imooc.com/article/21883
Docker由镜像、容器、仓库组成。
创建Dockerfile:
Docker中操作nginx:
查看镜像:docker images
查看正在运行的容器:docker ps
启动nginx:
docker run -p 8081:80 -d nginx
停止nginx:
docker stop 31169e74ea7a
--------------------------------Nginx--------------------------------------
安装Nginx:https://www.aliyun.com/jiaocheng/120780.html
创建一个目录:
mkdir -p ~/nginx/www ~/nginx/logs ~/nginx/conf
nginx安装目录: ~/nginx
启动nginx:(注:需在~/nginx目录下启动命令)
docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v$PWD/conf.d:/etc/nginx/conf.d --privileged=true -v $PWD/logs:/www/logs -v $PWD/html:/etc/nginx/html -d nginx
运行以上命令时报以下错误:
原因为nginx.conf目录不正确:
$PWD/conf/nginx.conf/nginx.conf:/etc/nginx/nginx.conf
改成如下,并运行成功:
docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf/nginx.conf:/etc/nginx/nginx.conf -v$PWD/conf.d:/etc/nginx/conf.d --privileged=true -v $PWD/logs:/www/logs -v $PWD/html:/etc/nginx/html -d nginx