#1、搜索ngnix镜像[root@rufeng /]# docker search nginx#2、拉取镜像 latest[root@rufeng /]# docker pull nginx#3、启动 nginx默认端口为80# -p 宿主机端口:容器内部端口[root@rufeng /]# docker run -d --name="nginx01" -p 10001:80 nginx
e4ad9fd04f425267d0604c31456c64df988f7498d433a62c23ae1904a904a665
[root@rufeng /]# docker ps
CONTAINER ID IMAGE COMMAND CREATED
e4ad9fd04f42 nginx "/docker-entrypoint.…" 2 seconds ago
#4、通过curl localhost:10001 测试[root@rufeng /]# curl localhost:10001<!DOCTYPE html><html><head><title>Welcome to nginx!</title><style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;}</style></head><body><h1>Welcome to nginx!</h1><p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p></body></html>#5、在外网进行访问(需要开放10001端口),出现下面所示,表示成功