1. 下载镜像 ```shell docker pull nginx

    [root@lxt ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest d1a364dc548d 9 days ago 133MB hello-world latest d1165f221234 3 months ago 13.3kB centos latest 300e315adb2f 5 months ago 209MB

    1. 2. 关闭虚拟机的防火墙
    2. ```shell
    3. systemctl status firewalld
    4. systemctl stop firewalld
    1. 创建并运行容器 ```shell docker run -d —name nginx01 -p 3344:80 nginx

    容器外部的3344给容器内的80做一个映射,通过3344就能访问80的内容了

    run命令可以直接帮你下载,少了docker pull xx 这一步

    1. 4. 访问页面
    2. ```shell
    3. [root@lxt ~]# curl localhost:3344
    4. <!DOCTYPE html>
    5. <html>
    6. <head>
    7. <title>Welcome to nginx!</title>
    8. <style>
    9. body {
    10. width: 35em;
    11. margin: 0 auto;
    12. font-family: Tahoma, Verdana, Arial, sans-serif;
    13. }
    14. </style>
    15. </head>
    16. <body>
    17. <h1>Welcome to nginx!</h1>
    18. <p>If you see this page, the nginx web server is successfully installed and
    19. working. Further configuration is required.</p>
    20. <p>For online documentation and support please refer to
    21. <a href="http://nginx.org/">nginx.org</a>.<br/>
    22. Commercial support is available at
    23. <a href="http://nginx.com/">nginx.com</a>.</p>
    24. <p><em>Thank you for using nginx.</em></p>
    25. </body>
    26. </html>

    本机访问(不是虚拟机),要用虚拟机的地址192.168.198.128
    image.png