docker 安装 nginx

    1. #1. 搜索镜像 search 建议去docker 搜索,可以看到帮助文档
    2. #2. 下载 pull
    3. #3. 运行测试
    4. root@VM-24-6-centos home]# docker images
    5. REPOSITORY TAG IMAGE ID CREATED SIZE
    6. nginx latest 605c77e624dd 5 months ago 141MB
    7. centos latest 5d0da3dc9764 9 months ago 231MB
    8. # -d 后台运行
    9. # --name 给容器命名
    10. # -p宿主机端口:容器内部端口
    11. [root@VM-24-6-centos home]# docker run -d --name nginx01 -p 6800:80 nginx
    12. c0fad6cdda5ddf02f7163ca26bb528248cff391ad00c2bcd691945a45e350e58
    13. [root@VM-24-6-centos home]# docker ps
    14. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    15. c0fad6cdda5d nginx "/docker-entrypoint.…" 5 seconds ago Up 4 seconds 0.0.0.0:6800->80/tcp, :::6800->80/tcp nginx01
    16. [root@VM-24-6-centos home]# curl localhost:6800
    17. <!DOCTYPE html>
    18. <html>
    19. <head>
    20. <title>Welcome to nginx!</title>
    21. <style>
    22. html { color-scheme: light dark; }
    23. body { width: 35em; margin: 0 auto;
    24. font-family: Tahoma, Verdana, Arial, sans-serif; }
    25. </style>
    26. </head>
    27. <body>
    28. <h1>Welcome to nginx!</h1>
    29. <p>If you see this page, the nginx web server is successfully installed and
    30. working. Further configuration is required.</p>
    31. <p>For online documentation and support please refer to
    32. <a href="http://nginx.org/">nginx.org</a>.<br/>
    33. Commercial support is available at
    34. <a href="http://nginx.com/">nginx.com</a>.</p>
    35. <p><em>Thank you for using nginx.</em></p>
    36. </body>
    37. </html>
    38. #进入容器
    39. [root@VM-24-6-centos home]# docker exec -it nginx01 /bin/bash
    40. root@c0fad6cdda5d:/# whereis nginx
    41. nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
    42. root@c0fad6cdda5d:/# cd /etc/nginx
    43. root@c0fad6cdda5d:/etc/nginx# ls
    44. conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
    45. root@c0fad6cdda5d:/etc/nginx#

    端口暴露的概念:
    34.jpg
    思考问题:每次改动nginx文件都需要进入容器内部,是否可以在容器外部提供一个映射路径,映射到容器,外面修改容器内部就能自动修改? -V 数据集技术