using environment variables in a docker file basic

时间:2018-06-04 17:29:35

标签: docker dockerfile

Using the following docker file I am getting an error on RUN md $SiteFolderPath and I am not sure why every example I look at:

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

Indicates I am doing it correctly.

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}

I get an error message when building the docker file:

mkdir : Cannot bind argument to parameter 'Path' because it is null.

1 个答案:

答案 0 :(得分:0)

您链接到州的页面:

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%

相关问题