"Fossies" - the Fresh Open Source Software Archive

Member "PowerShell-7.2.6/demos/Docker-PowerShell/Docker-PowerShell.ps1" (11 Aug 2022, 1086 Bytes) of package /linux/misc/PowerShell-7.2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Microsoft PowerShell source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # Copyright (c) Microsoft Corporation.
    2 # Licensed under the MIT License.
    3 
    4 # 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
    5 # The only difference between them is the example container image is pulled & run.
    6 
    7 # Import the Docker module
    8 #    It's available at https://github.com/Microsoft/Docker-PowerShell
    9 Import-Module Docker
   10 
   11 # Pull the 'hello-world' image from Docker Hub
   12 Pull-ContainerImage hello-world # Linux
   13 # Pull-ContainerImage patricklang/hello-world # Windows
   14 
   15 # Now run it
   16 Run-ContainerImage hello-world # Linux
   17 # Run-ContainerImage patricklang/hello-world # Windows
   18 
   19 # Make some room on the screen
   20 cls
   21 
   22 # List all containers that have exited
   23 Get-Container | Where-Object State -EQ "exited"
   24 
   25 # That found the right one, so go ahead and remove it
   26 Get-Container | Where-Object State -EQ "exited" | Remove-Container
   27 
   28 # Now remove the container image
   29 Remove-ContainerImage hello-world
   30 
   31 # And list the container images left on the container host
   32 Get-ContainerImage