|
1 | 1 | --- |
2 | 2 | description: How to use PowerShell that's preinstalled in a Docker image. |
3 | | -ms.date: 08/01/2024 |
| 3 | +ms.date: 03/11/2025 |
4 | 4 | ms.devlang: powershell |
5 | 5 | ms.topic: conceptual |
6 | 6 | title: Using PowerShell in Docker |
7 | 7 | --- |
8 | 8 |
|
9 | 9 | # Using 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 | 14 | ## Finding 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. It's also expected that you are able to run Docker |
| 17 | +without `sudo` or local administrative rights. Please follow Docker's official [instructions][02] to |
| 18 | +install `docker` correctly. |
19 | 19 |
|
20 | | -The release containers derive from the official distribution image, then install dependencies, and |
21 | | -finally install the PowerShell package. |
22 | | - |
23 | | -These containers live at [Microsoft Artifact Registry][05]. |
24 | | - |
25 | | -For more information about these Docker images, visit the [PowerShell-Docker][02] repository on |
26 | | -GitHub. |
| 20 | +The .NET team publishes several Docker images designed for different development scenarios. The |
| 21 | +image for the .NET SDK contains PowerShell. For more information, see |
| 22 | +[Official .NET Docker images][01]. |
27 | 23 |
|
28 | 24 | ## Using PowerShell in a container |
29 | 25 |
|
30 | 26 | The following steps show the Docker commands required to download the image containing the latest |
31 | 27 | available stable version of PowerShell and start an interactive PowerShell session. |
32 | 28 |
|
33 | | -```console |
34 | | -docker run -it mcr.microsoft.com/powershell |
35 | | -``` |
36 | | - |
37 | | -Use the following command to download and run the image containing the latest available preview |
38 | | -version of PowerShell. |
| 29 | +The following command downloads the image containing the latest available stable versions of the |
| 30 | +.NET SDK and PowerShell. |
39 | 31 |
|
40 | 32 | ```console |
41 | | -docker run -it mcr.microsoft.com/powershell:preview |
| 33 | +docker pull mcr.microsoft.com/dotnet/sdk:9.0 |
42 | 34 | ``` |
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 | 35 |
|
50 | | -The following command is used to delete the Docker image when you no longer need it. |
| 36 | +Use the following command to start an interactive PowerShell session in the container. |
51 | 37 |
|
52 | 38 | ```console |
53 | | -docker rmi mcr.microsoft.com/powershell |
| 39 | +docker run -it mcr.microsoft.com/dotnet/sdk:9.0 pwsh |
54 | 40 | ``` |
55 | 41 |
|
56 | | -## Legal and Licensing |
57 | | - |
58 | | -PowerShell is licensed under the [MIT license][03]. |
| 42 | +To download and run the latest Long Term Support (LTS) version of PowerShell, change the image name |
| 43 | +to `mcr.microsoft.com/dotnet/sdk:8.0`. When you use these image tags, Docker downloads the |
| 44 | +appropriate image for your host operating system. If you want an image for a specific operating |
| 45 | +system, you can specify the operating system in the image tag. See the |
| 46 | +[Microsoft Artifact Registry][07] for a list of available tags. |
59 | 47 |
|
60 | | -### Windows Docker file and image licenses |
| 48 | +- For more information about tags, the [Supported tag policy][06] |
| 49 | +- For more information about supported operating systems, see the [Supported platforms policy][05] |
61 | 50 |
|
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: |
| 51 | +## Support lifecycle |
64 | 52 |
|
65 | | -- [Window Server Core][06] |
66 | | -- [Nano Server][04] |
| 53 | +Support for these images is governed by the [.NET support policy][03]. These images are provided for |
| 54 | +development and testing purposes only. If you need a production-ready image, you should build your |
| 55 | +own images. For more information about these Docker images, visit the [dotnet-docker][04] repository |
| 56 | +on GitHub. |
67 | 57 |
|
68 | | -### Telemetry |
| 58 | +## Telemetry |
69 | 59 |
|
70 | 60 | By default, PowerShell collects limited telemetry without personally identifiable information to |
71 | 61 | help aid development of future versions of PowerShell. To opt-out of sending telemetry, create an |
72 | 62 | environment variable called `POWERSHELL_TELEMETRY_OPTOUT` set to a value of `1` before starting |
73 | 63 | PowerShell from the installed location. The telemetry we collect falls under the |
74 | | -[Microsoft Privacy Statement][07]. |
| 64 | +[Microsoft Privacy Statement][08]. |
75 | 65 |
|
76 | 66 | <!-- 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/ |
| 67 | +[01]: /dotnet/architecture/microservices/net-core-net-framework-containers/official-net-docker-images |
| 68 | +[02]: https://docs.docker.com/engine/installation/ |
| 69 | +[03]: https://github.com/dotnet/core/blob/main/support.md |
| 70 | +[04]: https://github.com/dotnet/dotnet-docker |
| 71 | +[05]: https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-platforms.md |
| 72 | +[06]: https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md |
| 73 | +[07]: https://mcr.microsoft.com/en-us/artifact/mar/dotnet/sdk/about |
| 74 | +[08]: https://privacy.microsoft.com/privacystatement/ |
0 commit comments