拉取nginx
docker pull nginx
安装完成之后进行测试:
sudo docker run --name nginx-test -p 8081:80 -d nginx
docker ps ##查看nginx是否启动
在docker中部署nginx
mkdir -p /usr/local/bin/nginx/www /usr/local/bin/nginx/logs /usr/local/bin/nginx/conf
docker cp nginx:/etc/nginx/nginx.conf /usr/local/bin/nginx/conf
启动
docker run -d -p 8082:80 --name my-nginx -v /usr/local/bin/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/bin/nginx/www:/usr/share/nginx/html -v /usr/local/bin/nginx/logs:/var/log/nginx nginx
在/usr/local/bin/nginx/www 下创建 index.html
访问http://106.53.26.246:8082/