Run PowerShell Natively on Linux and Docker!

Microsoft just made a huge splash today, by announcing that PowerShell is now available on Linux! I created a launch video that demonstrates how to get PowerShell Core running inside a Docker container! You can see the video over on Microsoft’s MSDN Channel 9.

https://channel9.msdn.com/Shows/msftazure/Run-PowerShell-Natively-on-Linux-with-Docker

Check if PowerShell is Running in a Docker Container

If you’re writing a PowerShell script, and need to check to see if PowerShell is running inside a Docker Container, then you can use this simple function. It simply returns [bool] $true if it’s running inside a container, and [bool] $false if it’s not running inside a container!

function IsContainerized {
    [CmdletBinding()]
    param ()
    
    if ((Get-Content -Raw /proc/1/cgroup) -match 'docker') {
        $true
    } else {
        $false
    }
}