zoukankan      html  css  js  c++  java
  • 利用Docker volume修改Nginx Docker镜像里index.html

    通过这个小例子我们可以进一步加深对Docker volume概念的理解和使用方法。

    我们都知道运行基于Docker的Nginx镜像后,访问localhost能看到Nginx默认的首页,这个首页的位置是Nginx镜像内的/usr/share/nginx/html目录下面。

    假设我们有个需求,修改Nginx默认的首页成下面的内容:

    <html>
    <head>
    <title>Custom Website from my container</title>
    </head>
    <body>
    <h1>This is Jerry's custom website.</h1>
    <p>This website is served from my <a href="http://www.docker.com" target="_blank">SAP Docker</a> container.</p>
    </body>
    </html>
    

    下面是详细方法。

    命令行-v将主机目录nginx-html挂载到Nginx容器内的/usr/share/nginx/html目录内。

    docker run -d -p 1081:80 -v `pwd`/nginx-html:/usr/share/nginx/html --name jerry-custom nginx
    

    使用vi将主机目录nginx-html下面的index.html修改成自定义内容:

    通过交互式的方式进入到docker容器内部:

    docker exec -it jerry-custom /bin/sh
    

    发现Docker容器里的index.html也自动被修改了,内容和主机目录nginx-html下面的一致。

    localhost:1081即可看到修改过后的自定义Nginx首页:

    要获取更多Jerry的原创文章,请关注公众号"汪子熙":

  • 相关阅读:
    tf.placeholder函数说明
    网易雷火 游戏研发一面 5.7
    【python3】with的用法
    一分钟理解softmax函数(超简单)
    网易雷火 笔试 4.25
    cun
    HDU-2045-RPG上色(递推)
    HDU-2050-折线分割平面 (递推)
    POJ-2389-Bull Math(高精度乘法)
    HDU-1002-A + B Problem II(高精度加法)
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/10029809.html
Copyright © 2011-2022 走看看