From cfdba3c426c174c2d970c170ac5fa4b54233e682 Mon Sep 17 00:00:00 2001 From: Patrick Lang Date: Wed, 17 Aug 2016 21:01:12 -0700 Subject: [PATCH] Adding Docker-PowerShell demo (#1862) --- demos/Docker-PowerShell/Docker-PowerShell.ps1 | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 demos/Docker-PowerShell/Docker-PowerShell.ps1 diff --git a/demos/Docker-PowerShell/Docker-PowerShell.ps1 b/demos/Docker-PowerShell/Docker-PowerShell.ps1 new file mode 100644 index 0000000000..3517e80588 --- /dev/null +++ b/demos/Docker-PowerShell/Docker-PowerShell.ps1 @@ -0,0 +1,29 @@ +# This is a short example of the Docker-PowerShell module. The same cmdlets may be used to manage both local & remote machines, including both Windows & Linux hosts +# The only difference between them is the example container image is pulled & run. + +# Import the Docker module +# It's available at https://github.com/Microsoft/Docker-PowerShell +Import-Module Docker + +# Pull the 'hello-world' image from Docker Hub +Pull-ContainerImage hello-world # Linux +# Pull-ContainerImage patricklang/hello-world # Windows + +# Now run it +Run-ContainerImage hello-world # Linux +# Run-ContainerImage patricklang/hello-world # Windows + +# Make some room on the screen +cls + +# List all containers that have exited +Get-Container | Where-Object State -eq "exited" + +# That found the right one, so go ahead and remove it +Get-Container | Where-Object State -eq "exited" | Remove-Container + +# Now remove the container image +Remove-ContainerImage hello-world + +# And list the container images left on the container host +Get-ContainerImage \ No newline at end of file