1: 拉取镜像
docker search nginx
2:取最新版的 Nginx 镜像
docker pull nginx:latest
3: 查看本地镜像
docker images
4: 运容器
docker run --name nginx-test -p 8080:80 -d nginx
参数说明:
- --name nginx-test:容器名称。
- -p 8080:80: 端口进行映射,将本地 8080 端口映射到容器内部的 80 端口。
- -d nginx: 设置容器在在后台一直运行。
5: 安装成功
因为上一步骤我们将宿主机端口8080和容器内端口80,做了映射。我们测试的时候去访问宿主机8080端口。如果能看到nginx欢迎界面,则表示安装成功