Cannot delete files from wwwroot with Dockerfile

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.

  • Do I need to rebuild image when parent image is updated?
  • Docker in host mode cannot connect to database running on host
  • How would a provide a self-updating web application, delivered via docker image?
  • How to workaround “the input device is not a TTY” when using grunt-shell to invoke a script that calls docker run?
  • Docker container won't run 32 bit iperf executable copied with wget
  • Could not get page inside of the docker's container
  • 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
     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

    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.

  • Unable to access docker container via local host, webpack
  • Docker vs old approach (supervisor, git, your project)
  • How can I access internet in docker build?
  • Docker Container Best Practices
  • How to handle PHP project code in docker container
  • How to upgrade elasticbeanstalk docker version
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.