0

I'm trying this on Windows Server Core 2016 TP5. I have this simple Dockerfile:

FROM microsoft/iis

RUN powershell remove-item c:\inetpub\wwwroot\iisstart.*

The microsoft/iis image contains a couple of files (iisstart.htm and iisstart.png) in c:\inetpub\wwwroot. I'm trying to remove those files.

Here's the output from docker build:

c:\git\temp\test>docker build -t foo .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM microsoft/iis
 ---> c26f4ceb81db
Step 2 : RUN powershell remove-item c:\inetpub\wwwroot\iisstart.*
 ---> Running in 4d17a5ab86e5
 ---> d5f85251b3db
Removing intermediate container 4d17a5ab86e5
Successfully built d5f85251b3db

If I now start up a container and look in wwwroot, the files are still there.

docker run --rm -it foo cmd

Microsoft Windows [Version 10.0.14300]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>cd inetpub\wwwroot

C:\inetpub\wwwroot>dir
 Volume in drive C has no label.
 Volume Serial Number is 5664-BDCB

 Directory of C:\inetpub\wwwroot

05/19/2016  07:05 PM    <DIR>          .
05/19/2016  07:05 PM    <DIR>          ..
05/05/2016  03:27 PM               703 iisstart.htm
05/05/2016  03:27 PM            99,710 iisstart.png
               2 File(s)        100,413 bytes
               2 Dir(s)  21,209,399,296 bytes free

C:\inetpub\wwwroot>

While inside the running container, if I execute powershell remove-item c:\inetpub\wwwroot\iisstart.*, the files get deleted fine. Why doesn't the same command work in the dockerfile?

I've also tried del c:\inetpub\wwwroot\iisstart.* with similar results.

Anthony Chu
  • 37,170
  • 10
  • 81
  • 71

1 Answers1

0

You are going to wrong path C:\>cd inetpub\wwwroot

You have to go to your container path so:

After run -d your image

  1. docker exec -it "containerID" pwoershell
  2. C:\>cd inetpub\wwwroot
  3. ls

And that will be OK as your Dockerfiles works

Abdelilah El Aissaoui
  • 4,204
  • 2
  • 27
  • 47
nemo
  • 1