官术网_书友最值得收藏!

  • Deployment with Docker
  • Srdjan Grubor
  • 160字
  • 2021-07-02 23:22:13

Setting environment variables with ENV

ENV, unlike some of these other commands, should be mostly self-explanatory: it sets the environmental variables both in the Dockerfile and the container. Since we would need to keep re-typing /srv/www/html in our Dockerfile, in order to prevent typos and to ensure easy changes to our final server directory target, we set the SRV_PATH variable that we keep reusing with $SRV_PATH later. Generally for Docker containers, almost all the configurations to containers are done through environmental variables such as these, so expect to see this directive more in the later chapters.

Even though we don't use it in this example, you need to watch out when using environment variables in the CMD directive directly as it does not get expanded but runs directly. You can ensure that your variable gets expanded in CMD by using it as part of a shell command structure similar to this: CMD [ "sh", "-c", "echo", "$SRV_PATH" ].

主站蜘蛛池模板: 安阳县| 怀柔区| 集安市| 理塘县| 吴旗县| 肥城市| 云和县| 瑞金市| 清水河县| 大荔县| 鄂州市| 宁安市| 富阳市| 丽水市| 辽阳市| 宁波市| 察雅县| 金川县| 鞍山市| 连江县| 绥芬河市| 平谷区| 江达县| 县级市| 苏尼特右旗| 揭东县| 墨竹工卡县| 外汇| 阿荣旗| 昌吉市| 桃园市| 道孚县| 遂宁市| 衡东县| 连江县| 民丰县| 吐鲁番市| 泸西县| 渭南市| 崇州市| 南阳市|