forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocker-PowerShell.ps1
More file actions
29 lines (21 loc) · 1011 Bytes
/
Docker-PowerShell.ps1
File metadata and controls
29 lines (21 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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