PowerShell Core on smaller Linux distributions (eg. Alpine)

Created on 19 Aug 2016  路  6Comments  路  Source: PowerShell/PowerShell

I'd like to try to get PowerShell Core working on Alpine Linux, with the long term goal of being able to run lightweight PowerShell Core Docker containers. The Docker container images I built using Ubuntu 16 and CentOS 7 are a bit on the large side.

So far, we know the following:

  • .NET Core is included with the PowerShell Core distributions
  • .NET Core has a dependency on libicu52 and libunwind8

What we need to figure out:

  • How to install or compile libicu52 on Alpine Linux
  • How to install or compile libunwind8 on Alpine Linux
  • How to install or compile PowerShell Core binaries on Alpine Linux

Anyone want to provide some insight to this effort?

Cheers,
Trevor Sullivan
Docker Captain
Microsoft MVP: Cloud & Data Center Management
https://trevorsullivan.net
https://twitter.com/pcgeek86

Area-Maintainers-Build Up-for-Grabs

Most helpful comment

So, I talked with the .NET team, and discovered that there's a microsoft/dotnet:core image that's only 250 MB. By inspecting the Dockerfile for .NET Core dependencies, I was able to produce a smaller Docker image for PowerShell Core, than what was possible with Ubuntu and CentOS 7. I used the Dockerfile statements from the .NET Core dependencies base image, and extended it to include PowerShell Core from a local build context. That avoided the need to install curl or wget along with extra dependencies.

Now, the Docker image based on Debian Jessie is only 334.3 MB.

https://twitter.com/pcgeek86/status/769239625047035904
https://hub.docker.com/r/trevorsullivan/powershell/

PS C:\Users\TrevorSullivan\PowerShellCore> docker images trevorsullivan/powershell
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
trevorsullivan/powershell   jessie              4abfcbcdfcf8        16 minutes ago      334.3 MB
trevorsullivan/powershell   centos7             6d7da3eb764b        7 days ago          571.5 MB
trevorsullivan/powershell   latest              3cbb7892a31c        8 days ago          537.1 MB

It's still not as small as we could get with Alpine Linux, but it's a huge improvement.

All 6 comments

Seems like you need .NET Core for Alpine first: https://github.com/dotnet/coreclr/issues/917

For libicu52 : https://pkgs.alpinelinux.org/package/edge/main/x86_64/icu-libs
For libunwind8 : https://pkgs.alpinelinux.org/package/edge/main/x86_64/libunwind

You can search for anything on https://pkgs.alpinelinux.org/packages with regex.
So i search the libs like icu , unwind
But i am not sure whether they are the one you wanted or not..

Have fun...

We ported couple of libraries along the way such as lldb, then @benpye did the libunwind and @mjeanson blessed us with liblttng-ust on Alpine Linux via aports packaging system. I also made some strides on the xbps front (package manager for Void Linux, which ships with two variants: musl-libc and glibc) and requested those fellas to add couple of related patches and libs to unblock CoreCLR build. As a result, CoreCLR up until very recently, was building on Alpine Linux as well as Void Linux (musl) and passing all the "PAL tests". Due to a recent change in CoreCLR code base, there is a blocker I am hitting https://github.com/dotnet/coreclr/issues/917#issuecomment-236907708 and hence the progress has been scrambled. Hopefully it won't stay like that for very long.

So, I talked with the .NET team, and discovered that there's a microsoft/dotnet:core image that's only 250 MB. By inspecting the Dockerfile for .NET Core dependencies, I was able to produce a smaller Docker image for PowerShell Core, than what was possible with Ubuntu and CentOS 7. I used the Dockerfile statements from the .NET Core dependencies base image, and extended it to include PowerShell Core from a local build context. That avoided the need to install curl or wget along with extra dependencies.

Now, the Docker image based on Debian Jessie is only 334.3 MB.

https://twitter.com/pcgeek86/status/769239625047035904
https://hub.docker.com/r/trevorsullivan/powershell/

PS C:\Users\TrevorSullivan\PowerShellCore> docker images trevorsullivan/powershell
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
trevorsullivan/powershell   jessie              4abfcbcdfcf8        16 minutes ago      334.3 MB
trevorsullivan/powershell   centos7             6d7da3eb764b        7 days ago          571.5 MB
trevorsullivan/powershell   latest              3cbb7892a31c        8 days ago          537.1 MB

It's still not as small as we could get with Alpine Linux, but it's a huge improvement.

@pcgeek86 do our new containers fit your need?

fyi Alpine discussion continued here https://github.com/PowerShell/PowerShell/issues/4605, anyone wants to chime with a docker, now is the time!

Was this page helpful?
0 / 5 - 0 ratings