none
Switching isolation mode for existing container RRS feed

  • Question

  • Hi

    I can create either a Windows Server container or a Hyper-V container just fine.

    This will create and start a Windows Server container: docker run -d --name iis-svr1 mhb/iisaspdemo ping -t localhost

    This will create and start a Hyper-V container: docker run -d --isolation=hyperv --name iis-hv-01 mhb/iisaspdemo ping -t localhost

    If i then use the command: docker inspect <containername> and look for isolation tag in the output, it will say either Process (for Windows Server container) or HyperV for a Hyper-V container.

    Is there any way of convert a existing Windows Server container to a Hyper-V container using docker and what command would I use.

    /Michael Bcuhardt

    Tuesday, April 25, 2017 12:19 PM

All replies


  • Once a container is running I don't think it's possible to to convert.

    Is there any reason you can't just kill the container and spin up a new one in the isolated runtime?

    What are you trying to accomplish?

    Thursday, April 27, 2017 6:42 PM
  • Hi Myles

    I know that I cannot make the change on a running container. Let's say that I execute the command: docker run -d --name iis-svr1 mhb/iisaspdemo ping -t localhost

    I now have a running container called iis-svr1 and it is running as a Windows Server container (process isolation mode). I now stop the container and would like to change the isolation mode to Hyper-V. Which docker command should I use to do that.

    I cannot use the docker run -d --isolation=hyperv --name iis-hv-01 mhb/iisaspdemo ping -t localhost because docker complains about the container already exists and the docker start command does not include the --isolation flag.

    /Michael Buchardt

    Friday, April 28, 2017 2:45 PM
  • Ah OK thanks for explaining further!

    I think I know what your issue is now.  

    When you exit a container, you still have an exited copy of the container on your system.  This can be used to start a new container of the same type faster.  But since you can't convert a Server container to a Hyper-V container, if they have the same name you'll run into problems.

    To list exited containers, you can use this command:

    docker ps -a -f status=exited

    To remove stopped containers, you can use this command.

    $ docker rm $(docker ps -a -q)

    The rm command is documented further on the Docker docs here 

    Let me know if this works or doesn't.  Happy to help further :)

    Cheers,

    Myles

    • Proposed as answer by Myles Keating Wednesday, May 3, 2017 7:38 PM
    Friday, April 28, 2017 6:35 PM