Developers writing code on any platform struggle with keeping dependencies up-to-date, and ensuring that their software works with the latest and greatest runtime. PowerShell script and module developers are no different. Although PowerShell has a pretty strong history of not breaking things in new releases, it does happen occasionally. For more information about breaking changes in the latest release, check out the Microsoft documentation.
Since PowerShell has been open sourced and made cross-platform in 2016, thanks to the .NET Core framework, developers have enjoyed the ability to run PowerShell on Linux and MacOS natively, in addition to Windows.
Run PowerShell on Linux Containers
Because PowerShell can run on Linux, it’s also implied that PowerShell can be packaged up and run inside containers via Docker. Using Linux containers to run PowerShell provides a level of isolation between processes that prevent “cross-talk.” The version of PowerShell being used inside one container can be completely different from the version of PowerShell running in a separate container. Additionally, the PowerShell module versions that each of these containers has installed can be completely different.
If you’re brand new to Docker, the easiest way to get up and running is to install Docker Desktop on Windows 10 or MacOS. The reason that Docker Desktop isn’t available for Linux, is because Docker runs natively on Linux.
Run Multiple Versions of PowerShell in Containers
With the release of PowerShell 7.1.0 this week, the question came up on Reddit about how to run multiple versions of PowerShell in parallel, without conflicts. The obvious choice here is to use Docker to run PowerShell containers, using the pre-packaged container images provided by Microsoft. For people who are new to Docker containers, I’ve produced a video that describes how to install Docker Desktop, download PowerShell container images, and run multiple PowerShell containers side-by-side.
If you’re interested in learning how to run PowerShell side-by-side with Docker, check out my latest video on YouTube.
Even More Software Training at CBT Nuggets
If you’re interested in taking your software development and IT skills to the next level, check out the training I’ve been producing over at CBT Nuggets. We even offer a free CBT Nuggets account so you can get a feel for the quality that our trainers provide, before signing up for a subscription. Just FYI, you’ll need a Google account in order to sign up for a free CBT Nuggets account.
Some of the recent training skills I’ve published includes:
- Perform Facial Recognition with Python
- Send Windows Notifications with PowerShell
- Customize Microsoft Windows Terminal for Productivity
- Writing Intellisense for PowerShell Modules
- Build Serverless Functions with PowerShell and AWS Lambda