|
1 | 1 | --- |
2 | | -description: How to use PowerShell that's preinstalled in a Docker image. |
3 | | -ms.date: 08/01/2024 |
| 2 | +description: How to use PowerShell in a Docker image. |
| 3 | +ms.date: 03/11/2025 |
4 | 4 | ms.devlang: powershell |
5 | 5 | ms.topic: conceptual |
6 | | -title: Using PowerShell in Docker |
| 6 | +title: Use PowerShell in Docker |
7 | 7 | --- |
8 | 8 |
|
9 | | -# Using PowerShell in Docker |
| 9 | +# Use PowerShell in Docker |
10 | 10 |
|
11 | | -We publish Docker images with PowerShell preinstalled. This article shows you how to get |
12 | | -started using PowerShell in the Docker container. |
| 11 | +The .NET team publishes Docker images with PowerShell preinstalled. This article shows you how to |
| 12 | +get started using PowerShell in the Docker container. |
13 | 13 |
|
14 | | -## Finding available images |
| 14 | +## Find available images |
15 | 15 |
|
16 | | -The released images require Docker 17.05 or newer. It's also expected that you are able to run |
17 | | -Docker without `sudo` or local administrative rights. Please follow Docker's official |
18 | | -[instructions][01] to install `docker` correctly. |
| 16 | +These images require Docker 17.05 or newer. Also, you must be able to run Docker without `sudo` or |
| 17 | +local administrative rights. For install instructions, see Docker's official [documentation][02]. |
19 | 18 |
|
20 | | -The release containers derive from the official distribution image, then install dependencies, and |
21 | | -finally install the PowerShell package. |
| 19 | +The .NET team publishes several Docker images designed for different development scenarios. Only the |
| 20 | +image for the .NET SDK contains PowerShell. For more information, see |
| 21 | +[Official .NET Docker images][01]. |
22 | 22 |
|
23 | | -These containers live at [Microsoft Artifact Registry][05]. |
| 23 | +## Use PowerShell in a container |
24 | 24 |
|
25 | | -For more information about these Docker images, visit the [PowerShell-Docker][02] repository on |
26 | | -GitHub. |
27 | | - |
28 | | -## Using PowerShell in a container |
29 | | - |
30 | | -The following steps show the Docker commands required to download the image containing the latest |
31 | | -available stable version of PowerShell and start an interactive PowerShell session. |
| 25 | +The following command downloads the image containing the latest available stable versions of the |
| 26 | +.NET SDK and PowerShell. |
32 | 27 |
|
33 | 28 | ```console |
34 | | -docker run -it mcr.microsoft.com/powershell |
| 29 | +docker pull mcr.microsoft.com/dotnet/sdk:9.0 |
35 | 30 | ``` |
36 | 31 |
|
37 | | -Use the following command to download and run the image containing the latest available preview |
38 | | -version of PowerShell. |
39 | | - |
40 | | -```console |
41 | | -docker run -it mcr.microsoft.com/powershell:preview |
42 | | -``` |
43 | | -> [!IMPORTANT] |
44 | | -> The Docker images are built from official operating system (OS) images provide by the OS |
45 | | -> distributor. These images may not have the latest security updates. Microsoft recommends that you |
46 | | -> update the OS packages to the latest version to ensure the latest security updates are applied. |
47 | | -
|
48 | | -### Remove the image when no longer needed |
49 | | - |
50 | | -The following command is used to delete the Docker image when you no longer need it. |
| 32 | +Use the following command to start an interactive PowerShell session in the container. |
51 | 33 |
|
52 | 34 | ```console |
53 | | -docker rmi mcr.microsoft.com/powershell |
| 35 | +docker run -it mcr.microsoft.com/dotnet/sdk:9.0 pwsh |
54 | 36 | ``` |
55 | 37 |
|
56 | | -## Legal and Licensing |
| 38 | +To download and run the latest Long Term Support (LTS) version of PowerShell, change the image name |
| 39 | +to `mcr.microsoft.com/dotnet/sdk:8.0`. When you use these image tags, Docker downloads the |
| 40 | +appropriate image for your host operating system. If you want an image for a specific operating |
| 41 | +system, you can specify the operating system in the image tag. See the |
| 42 | +[Microsoft Artifact Registry][07] for a list of available tags. |
57 | 43 |
|
58 | | -PowerShell is licensed under the [MIT license][03]. |
| 44 | +- For more information about tags, the [Supported tag policy][06] |
| 45 | +- For more information about supported operating systems, see the [Supported platforms policy][05] |
59 | 46 |
|
60 | | -### Windows Docker file and image licenses |
| 47 | +## Support lifecycle |
61 | 48 |
|
62 | | -By requesting and using the Container OS Image for Windows containers, you acknowledge, understand, |
63 | | -and consent to the Supplemental License Terms available on Docker hub: |
| 49 | +The [.NET support policy][03] defines how these images are supported. These images are provided for |
| 50 | +development and testing purposes only. If you need a production-ready image, you should build your |
| 51 | +own images. For more information about these Docker images, visit the [dotnet-docker][04] repository |
| 52 | +on GitHub. |
64 | 53 |
|
65 | | -- [Window Server Core][06] |
66 | | -- [Nano Server][04] |
| 54 | +The images previously published by the PowerShell team will be marked as deprecated in the Microsoft |
| 55 | +Container Registry (MCR). |
67 | 56 |
|
68 | | -### Telemetry |
| 57 | +## Telemetry |
69 | 58 |
|
70 | | -By default, PowerShell collects limited telemetry without personally identifiable information to |
71 | | -help aid development of future versions of PowerShell. To opt-out of sending telemetry, create an |
72 | | -environment variable called `POWERSHELL_TELEMETRY_OPTOUT` set to a value of `1` before starting |
73 | | -PowerShell from the installed location. The telemetry we collect falls under the |
74 | | -[Microsoft Privacy Statement][07]. |
| 59 | +By default, PowerShell collects limited telemetry without personal data to help aid development of |
| 60 | +future versions of PowerShell. To opt-out of sending telemetry, create an environment variable |
| 61 | +called `POWERSHELL_TELEMETRY_OPTOUT` set to a value of `1` before starting PowerShell from the |
| 62 | +installed location. The telemetry we collect falls under the [Microsoft Privacy Statement][08]. |
75 | 63 |
|
76 | 64 | <!-- link references --> |
77 | | -[01]: https://docs.docker.com/engine/installation/ |
78 | | -[02]: https://github.com/PowerShell/PowerShell-Docker |
79 | | -[03]: https://github.com/PowerShell/PowerShell/tree/master/LICENSE.txt |
80 | | -[04]: https://mcr.microsoft.com/product/windows/nanoserver |
81 | | -[05]: https://mcr.microsoft.com/product/powershell |
82 | | -[06]: https://mcr.microsoft.com/product/windows/servercore |
83 | | -[07]: https://privacy.microsoft.com/privacystatement/ |
| 65 | +[01]: /dotnet/architecture/microservices/net-core-net-framework-containers/official-net-docker-images |
| 66 | +[02]: https://docs.docker.com/engine/installation/ |
| 67 | +[03]: https://github.com/dotnet/core/blob/main/support.md |
| 68 | +[04]: https://github.com/dotnet/dotnet-docker |
| 69 | +[05]: https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-platforms.md |
| 70 | +[06]: https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md |
| 71 | +[07]: https://mcr.microsoft.com/en-us/artifact/mar/dotnet/sdk/about |
| 72 | +[08]: https://privacy.microsoft.com/privacystatement/ |
0 commit comments