Skip to content

Latest commit

 

History

History
177 lines (137 loc) · 4.08 KB

Remove-DockerContainer.md

File metadata and controls

177 lines (137 loc) · 4.08 KB
external help file psdocker-help.xml
Module Name psdocker
online version https://abbgrade.github.io/psdocker/docs/Remove-DockerContainer.html
schema 2.0.0

Remove-DockerContainer

SYNOPSIS

Remove a Docker container.

SYNTAX

Remove-DockerContainer [-Name] <String> [-Force] [[-Timeout] <Int32>] [[-StopTimeout] <Int32>]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

Removes a container, optionally stopping it first with -Force. Supports -WhatIf and -Confirm. Wraps the Docker CLI `rm` command.

EXAMPLES

EXAMPLE 1

# 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
Remove-DockerContainer -Name $name -Force

Creates a temporary container, then removes it by name. Captured output: No output. The container is removed.

EXAMPLE 2

# 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'))"
$container = New-DockerContainer -Image 'mcr.microsoft.com/powershell:latest' -Name $name -Detach -ArgumentList @('sleep','infinity')
$container | Remove-DockerContainer -Force

Creates a temporary container, then stops and removes it through the pipeline. Captured output: No output. Matching containers are stopped and removed.

PARAMETERS

-Name

Specifies the name of the container that should be removed.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Force

Specifies if the container should be stopped before removal.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Timeout

Specifies the number of seconds to wait for the command to finish.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: 10
Accept pipeline input: False
Accept wildcard characters: False

-StopTimeout

Specifies the timeout of the Docker client command for the stop operation.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: 10
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

RELATED LINKS

https://abbgrade.github.io/psdocker/docs/Remove-DockerContainer.html

https://docs.docker.com/engine/reference/commandline/rm/