Update File On Run or Create

Hi all,

I am trying to use the same docker image for several containers. The only difference between these containers is the connection string in my web.config. I know it’s possible to have build arguments when building the image but I want to do a string replace and Set-Content on docker create or run in order to use the same image. I have tried using entrypoint powershell -c “Get-Date | Set-Content C:/Program Files/App/web.config” just as a test but this is not working for me and appears to do nothing at all. Any help on the proper syntax or another method of solving this problem would be appreciated.

May be “swarm secrets” are the way to go. see: https://docs.docker.com/engine/swarm/secrets/ … just an idea

I was able to get it working the way I had hoped. Though I am still working out some details in the provisioning script, this is how I ended up getting the result I wanted from the docker side of things. I came to this result by trial and error and I wish I could find an explanation as to why I needed an entry point and why I couldn’t use the shell directive.

FROM microsoft/aspnet:3.5-windowsservercore-10.0.14393.1198

#The shell line needs to be removed and any RUN commands need to be immediately proceeded by ‘powershell’ eg RUN powershell ping google.com
#SHELL [“powershell”, “-Command”, “$ErrorActionPreference = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’;”]

COPY *.ps1 /Container/

COPY [“wwwroot”, “/inetpub/wwwroot”]
COPY [“Admin”, “/Program Files (x86)Admin”]
COPY [“Admin/web.config”, “/Program Files (x86)/Admin/web_default.config”]

ENV myParm1 Hiiii
ENV myParm2 123
ENTRYPOINT [“powershell”, “-NoProfile”, “-Command”, “C:\Container\Start-Admin.Docker.Cmd.ps1”]
CMD [“-parm1 $Env:myParm1 -parm2 $Env:myParm2”]

The docker run command looks like this

docker run -d -p 8001:80 -e “myParm1=byeeeee” --name=container image:v1

I hope this helps someone else that is in my boat.