Open mikefrobbins opened 1 year ago
Expected behavior
For the architecture to be automatically detected to run on either x64 or ARM without requiring specific tags to be specified.
Thats how properly tagged docker images should work. Specially when a manifest was provided and they have been properly build for the requested arches.
You can see there in this thread https://github.com/PowerShell/PowerShell/issues/20143 that PowerShell currently is lacking a lot when it comes to linux:
x84_x64
(AMD64
) and for some OS even arm64
& arm32
.You are using no tag, which AFAIK fallsback to the tag latest
, which you can see when pulling the image: Using default tag: latest
.
The Repo PowerShell
does not have any arches listed on the tag latest
- which is weird:
When running:
docker pull mcr.microsoft.com/powershell && docker image inspect mcr.microsoft.com/powershell | grep "Architecture"
On my AMD64 Server I get:
"Architecture": "amd64",
When I run it on my linux based Apple Mini M1 I get:
"Architecture": "arm",
Which is wrong, since it is a ARM64 chip. Testing with docker run -it mcr.microsoft.com/powershell
(like the OP) results in:
$ docker run -it mcr.microsoft.com/powershell
exec /usr/bin/pwsh: exec format error
cc @anamnavi for visibility
Although it does not resolve the original issue (using latest should support multiple architectures) I found out that there is version tagged as preview-mariner-2.0-arm64
which runs smoothly on my MacBook Pro M2, doing an inspect of the image shows indeed:
"Architecture": "arm64",
"Os": "linux",
It runs PS 7.4.0-preview:
/Users/olivier.vanekem % docker run -it mcr.microsoft.com/powershell:preview-mariner-2.0-arm64
PowerShell 7.4.0-preview.4
PS /> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.0-preview.4
PSEdition Core
GitCommitId 7.4.0-preview.4
OS CBL-Mariner/Linux
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@ovanekem but this is of less value.
When I ru this on my Mac Mini M1 I get:
$ docker run -it mcr.microsoft.com/powershell:preview-mariner-2.0-arm64
PowerShell 7.4.0-preview.5
PS /> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.0-preview.5
PSEdition Core
GitCommitId 7.4.0-preview.5
OS CBL-Mariner/Linux
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
The problem is, this command:
docker pull mcr.microsoft.com/powershell && docker image inspect mcr.microsoft.com/powershell | grep "Architecture"
still shows:
"Architecture": "arm",
Which is wrong. My Mac Mini M1 is a arm64
/aarch64
based CPU, not a arm
based CPU.
I tested on a 64 bit Raspberry PI, and it is a 32 bit image, arch
shows the real CPU
$ docker run -it --rm mcr.microsoft.com/powershell
PowerShell 7.4.0
PS /> dpkg --print-architecture
armhf
PS /> arch
aarch64
PS />
PS /> ldd /usr/bin/pwsh
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xf7e60000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xf7e40000)
libstdc++.so.6 => /lib/arm-linux-gnueabihf/libstdc++.so.6 (0xf7cb0000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xf7c50000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xf7c20000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xf7af0000)
/lib/ld-linux-armhf.so.3 (0xf7ec4000)
So the solution to accessing Powershell on MacOS (because apparently adding a wrapper for Set-MsolDomainFederationSettings inside Office 365 Admin Center to setup SSO through Google would be too easy) is to use mcr.microsoft.com/powershell:preview-mariner-2.0-arm64? Really? Am I the only one in the world that wants to use gmail and teams through the same account? What simple thing have I missed thats ended me up here? Apologies for cluttering this issue however I don't think I will be the only one that ends up here trying to get the same result.
So the solution to accessing Powershell on MacOS
You could use any Debian based Docker image and install PowerShell yourself, and there is no issue with you creating your own Dockerfile with that base image and adding any particular version of PowerShell.
Using no tags or latest tag is fraught with danger because you could end up with any wrong architecture, pre-release or bug-ridden version. Best practice is to specify the image you want, unless you actually don't care.
I'll look into this and adding a manifest for arm so that it's clearer experience
Prerequisites
Steps to reproduce
Use one of the following commands to run the PowerShell Docker container on an ARM based system such as a Mac M1 or M2 based system:
No tags:
Latest tag:
Expected behavior
Actual behavior
Error details
Environment data
Visuals