Using PowerShell in Docker

We publish Docker images with PowerShell preinstalled. This article shows you how to get started using PowerShell in the Docker container.

Finding available images

The released images require Docker 17.05 or newer. It's also expected that you are able to run Docker without sudo or local administrative rights. Please follow Docker's official instructions to install docker correctly.

The release containers derive from the official distribution image, then install dependencies, and finally install the PowerShell package.

These containers live at Microsoft Artifact Registry.

For more information about these Docker images, visit the PowerShell-Docker repository on GitHub.

Using PowerShell in a container

The following steps show the Docker commands required to download the image containing the latest available stable version of PowerShell and start an interactive PowerShell session.

docker run -it mcr.microsoft.com/powershell

Use the following command to download and run the image containing the latest available preview version of PowerShell.

docker run -it mcr.microsoft.com/powershell:preview

Remove the image when no longer needed

The following command is used to delete the Docker image when you no longer need it.

docker rmi mcr.microsoft.com/powershell

PowerShell is licensed under the MIT license.

Windows Docker file and image licenses

By requesting and using the Container OS Image for Windows containers, you acknowledge, understand, and consent to the Supplemental License Terms available on Docker hub:

Telemetry

By default, PowerShell collects limited telemetry without personally identifiable information to help aid development of future versions of PowerShell. To opt-out of sending telemetry, create an environment variable called POWERSHELL_TELEMETRY_OPTOUT set to a value of 1 before starting PowerShell from the installed location. The telemetry we collect falls under the Microsoft Privacy Statement.