| external help file | psdocker-help.xml |
|---|---|
| Module Name | psdocker |
| online version | https://abbgrade.github.io/psdocker/docs/Get-DockerContainer.html |
| schema | 2.0.0 |
Get Docker containers.
Get-DockerContainer [-Running] [-Latest] [[-Name] <String>] [[-Timeout] <Int32>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
Returns container information and can filter by running state, latest container, or name. Wraps the Docker CLI `ps` command.
# Prerequisites: Docker is running and can pull images from Microsoft Container Registry.
Install-DockerImage -Repository 'mcr.microsoft.com/powershell' -Tag 'latest' | Out-Null
$name = "psdocker-example-$([guid]::NewGuid().ToString('N'))"
New-DockerContainer -Image 'mcr.microsoft.com/powershell:latest' -Name $name -Detach -ArgumentList @('sleep','infinity') | Out-Null
Get-DockerContainer -Running -Name $name | Format-List Id,Name,Image,Status
Remove-DockerContainer -Name $name -Force
Creates a temporary running container, lists it, then removes it. Captured output (temporary container ID and generated name redacted): Id : <redacted> Name : psdocker-example-... Image : mcr.microsoft.com/powershell:latest Status : Up Less than a second
# Prerequisites: Docker is running and can pull images from Microsoft Container Registry.
$name = "psdocker-example-$([guid]::NewGuid().ToString('N'))"
Install-DockerImage -Repository 'mcr.microsoft.com/powershell' -Tag 'latest' | Out-Null
New-DockerContainer -Image 'mcr.microsoft.com/powershell:latest' -Name $name -Detach -ArgumentList @('sleep','infinity') | Out-Null
Get-DockerContainer -Name $name | Format-List Id,Name,Image,Status
Remove-DockerContainer -Name $name -Force
Finds a container by name, then removes the temporary container. Captured output (temporary container ID and generated name redacted): Id : <redacted> Name : psdocker-example-... Image : mcr.microsoft.com/powershell:latest Status : Up Less than a second
Specifies if only running containers should be returned.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies if only the latest created container should be returned.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies if only the container with the given name should be returned.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the number of seconds to wait for the command to finish.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
https://abbgrade.github.io/psdocker/docs/Get-DockerContainer.html