簡體   English   中英

在docker文件基本中使用環境變量

[英]using environment variables in a docker file basic

使用以下泊塢窗文件,我在RUN md $ SiteFolderPath上遇到錯誤,並且我不確定為什么我看的每個示例:

https://docs.docker.com/engine/reference/builder/#environment-replacement

表示我做得正確。

FROM microsoft/iis
#FROM nanoserver/iis

SHELL ["powershell"]

ENV SiteFolderPath c:\\app
ENV SiteFolderPathLogs c:\\app\\logs
ENV WorkFolder /app

ENV SiteAppPool LocalAppPool
ENV SiteName LocalWebSite
ENV SiteHostName LocalSite

RUN md $SiteFolderPath
RUN md $SiteFolderPathLogs
WORKDIR $WorkFolder


COPY ./Public .

RUN New-Item $SiteFolderPath -type Directory
RUN Set-Content $SiteFolderPath\Default.htm "<h1>Hello IIS</h1>"
RUN New-Item IIS:\AppPools\$SiteAppPool
RUN New-Item IIS:\Sites\$SiteName -physicalPath $SiteFolderPath -bindings @{protocol="http";bindingInformation=":80:"+$SiteHostName}
RUN Set-ItemProperty IIS:\Sites\$SiteName -name applicationPool -value $SiteAppPool

EXPOSE 80
EXPOSE 443

VOLUME ${SiteFolderPathLogs}

構建docker文件時出現錯誤消息:

mkdir:無法將參數綁定到參數'Path',因為它為null。

您鏈接到的頁面指出:

Environment variables are supported by the following list of instructions in the Dockerfile:

ADD
COPY
ENV
EXPOSE
FROM
LABEL
STOPSIGNAL
USER
VOLUME
WORKDIR

as well as:

ONBUILD (when combined with one of the supported instructions above)

由於將變量用作RUN塊的一部分,因此應使用Windows環境變量語法:%SiteFolderPath%

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM