Skip to content
abbgradePublic

About

Powershell Cmdlets that wrap the docker client and support the interaction with containers

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Repository files navigation

psdocker

.github/workflows/build-validation.yml

psdocker integrates Docker into PowerShell-based DevOps workflows, including test automation. It wraps the Docker CLI with commands to find and manage images and containers, and to run commands inside containers.

For details, visit the GitHub Pages.

Installation

Make sure PowerShell 7.0 or later and the Docker CLI are installed. You can install Docker, for example, via Chocolatey or Docker Desktop.

Install psdocker from the PowerShell Gallery in a PowerShell session:

Install-Module -Name psdocker -Scope CurrentUser

Quick start

With Docker running and access to Microsoft Container Registry, pull a PowerShell image, start a container, run a command in it, and remove it:

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')

try {
    Invoke-DockerCommand -Name $container.Name -Command 'echo' -ArgumentList 'hello' -StringOutput
}
finally {
    Remove-DockerContainer -Name $container.Name -Force
}

Build

This project uses a build script based on Invoke-Build. For installation details, see the Invoke-Build documentation; we recommend Install-Module InvokeBuild -Scope CurrentUser. The documentation is generated with platyPS, so you may also want to run Install-Module PlatyPs -Scope CurrentUser.

You can run the build by:

  • PowerShell: execute Invoke-Build in a PowerShell session in the project directory
  • VS Code: run the integrated build task feature (F1 + "Tasks: Run Build Task")

Test

This project uses test scripts based on Pester. For installation details, see the Pester documentation; we recommend Install-Module Pester -Scope CurrentUser.

You can run the tests by:

  • PowerShell: execute Invoke-Build Test in a PowerShell session in the project directory
  • VS Code: run the integrated test task feature (F1 + "Tasks: Run Test Task")

For debugging tests, change the working directory to ./test, set a breakpoint in VS Code, and start debugging with F1 + "Debug: Start Debugging".

Usage

See the command reference for descriptions and examples.

Changelog

See the changelog file.

Contributors

Thanks to the contributors of this project:

  • Steffen Kampmann
  • Marc Kassay

About

Powershell Cmdlets that wrap the docker client and support the interaction with containers

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages