创建一个容器并把容器端口随机在物理机映射一个端口
docker run --name nginx -p 80 -itd centos
docker exec -it nginx /bin/bash
修改yum源并安装wget
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
安装wget、nginx、vim
yum install wget -y
yum install nginx -y
yum install vim-enhanced -y
4.创建静态页面
mkdir /var/www/html -p
cd /var/www/html/
cat index.html
<html>
<head>
<title>nginx in docker</title>
</head>
<body>
<h1>hello</h1>
</body>
</html>
修改nginx配置文件中的root路径,并启动nginx
vim /etc/nginx/nginx.conf
root /var/www/html/;
/usr/sbin/nginx