1

I am trying to build a Docker container which runs 2 external scripts, whenever my Docker daemon parses the lines containing the 'RUN' parameter they don't seem to be doing the install and setup I ask of them.

RUN CMD powershell -Command net user anon Nona /add;
CMD powershell -Command wmic useraccount where "name='anon'"; \
CMD powershell -Command net localgroup User /add; \
CMD powershell -Command 'C:\Users\anon\getGNUPG_ALT.bat > output.log;' ;  \
CMD powershell -Command 'C:\Users\anon\getTor.bat' ;

To test this container I am building the image and running it in a container (docker build -rm mycontainer). Whenever I run the %username% command I get the containerAdministrator as the output and my batch files have not installed anything.

Is there an issue with my syntax in the DockerFile or could the batch files be the problem?

kr1pt0
  • 11
  • 1

1 Answers1

1

I think you are confusing between these two commands RUN and CMD.

To answers at your question, you can put off the "RUN" at the start because you can't encapsulate two commands in a Dockerfile. Or replace all CMD by RUN commands:

RUN powershell -Command net user anon Nona /add;
RUN powershell -Command wmic useraccount where "name='anon'"; \
RUN powershell -Command net localgroup User /add; \
RUN powershell -Command 'C:\Users\anon\getGNUPG_ALT.bat > output.log;' ;  \
RUN powershell -Command 'C:\Users\anon\getTor.bat' ;

Furthermore, it seems that CMD command syntax is not respected, please see the officiel documentation: https://docs.docker.com/engine/reference/builder/

You can also look at this existed question : What's the difference between RUN and CMD in a docker file and when should I use one or the other?.

Finally, If you Google it, you’ll find tutorials that can explain it much better than we can in an answer here, here an example : https://4sysops.com/archives/create-a-docker-container-on-windows-with-a-dockerfile/

GoA Oz
  • 328
  • 1
  • 13