docker安装并部署nginx
安装nginx镜像
docker pull nginx
创建并后台运行nginx容器,命名为nginx01,指定主机和容器端口之间的映射
docker run -d --name nginx01 -p 3344:80 nginx
本机自测
[root@iZmu0fa4hv0jwzZ home]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 03ae4ad1999f nginx "/docker-entrypoint.…" 5 seconds ago Up 3 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01 [root@iZmu0fa4hv0jwzZ home]# curl localhost:3344 <!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>
可以看见welcome to nginx
端口暴露的概念