Alpine Linux への PowerShell のインストール
すべてのパッケージは GitHub リリース ページにあります。 パッケージがインストールされたら、ターミナルから pwsh
を実行します。 プレビュー リリースをインストールした場合は、pwsh-preview
を実行します。 インストールする前に、後述の「サポートされているバージョン」の一覧を確認してください。
Note
PowerShell 7.4 はインプレース アップグレードであり、以前のバージョンの PowerShell 7 は削除されます。 PowerShell のプレビュー バージョンは、他のバージョンの PowerShell と一緒にインストールできます。 PowerShell 7.4 と以前のバージョンを side-by-side 実行する必要がある場合は、バイナリ アーカイブの方法を使用して以前のバージョンを再インストールします。
Note
この記事のインストール コマンドは、PowerShell の最新の安定したリリース用です。 別のバージョンの PowerShell をインストールするには、必要なバージョンに合わせてコマンドを調整します。 次のリンクを使用すると、GitHub の PowerShell リポジトリの各バージョンのリリース ページに移動します。
- v7.5.0 - 安定版リリース: https://aka.ms/powershell-release?tag=stable
- v7.4.7 - LTS リリース: https://aka.ms/powershell-release?tag=lts
- v7.6.0-preview.2 - プレビュー リリース: https://aka.ms/powershell-release?tag=preview
すべてのパッケージのダウンロード リンクは、リリース ページの [Assets] セクションにあります。 [Assets] セクションは折りたたまれている場合があります。その場合は、クリックして展開する必要があります。
インストール手順
Alpine へのインストールは、リリース ページから tar.gz パッケージをダウンロードする方法に基づいて行います。 パッケージの URL は、インストールする PowerShell のバージョンによって異なります。
- PowerShell 7.4 -
https://github.com/PowerShell/PowerShell/releases/download/v7.4.7/powershell-7.4.7-linux-musl-x64.tar.gz
- PowerShell 7.5 -
https://github.com/PowerShell/PowerShell/releases/download/v7.5.0/powershell-7.5.0-linux-musl-x64.tar.gz
次に、ターミナルで次のシェル コマンドを実行して、PowerShell 7.4 をインストールします。
# install the requirements
sudo apk add --no-cache \
ca-certificates \
less \
ncurses-terminfo-base \
krb5-libs \
libgcc \
libintl \
libssl3 \
libstdc++ \
tzdata \
userspace-rcu \
zlib \
icu-libs \
curl
apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \
lttng-ust \
openssh-client \
# Download the powershell '.tar.gz' archive
curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.5.0/powershell-7.5.0-linux-musl-x64.tar.gz -o /tmp/powershell.tar.gz
# Create the target folder where powershell will be placed
sudo mkdir -p /opt/microsoft/powershell/7
# Expand powershell to the target folder
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7
# Set execute permissions
sudo chmod +x /opt/microsoft/powershell/7/pwsh
# Create the symbolic link that points to pwsh
sudo ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh
# Start PowerShell
pwsh
PowerShell のアンインストール
sudo rm -rf /usr/bin/pwsh /opt/microsoft/powershell
PowerShell のパス
$PSHOME
は/opt/microsoft/powershell/7/
です- プロファイル スクリプトは、次の場所に格納されます。
- AllUsersAllHosts -
$PSHOME/profile.ps1
- AllUsersCurrentHost -
$PSHOME/Microsoft.PowerShell_profile.ps1
- CurrentUserAllHosts -
~/.config/powershell/profile.ps1
- CurrentUserCurrentHost -
~/.config/powershell/Microsoft.PowerShell_profile.ps1
- AllUsersAllHosts -
- モジュールは、次の場所に格納されます。
- ユーザー モジュール -
~/.local/share/powershell/Modules
- 共有モジュール -
/usr/local/share/powershell/Modules
- 既定のモジュール -
$PSHOME/Modules
- ユーザー モジュール -
- PSReadLine 履歴は
~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt
に記録されます
プロファイルは PowerShell のホスト別構成を順守します。そのため、既定のホスト固有プロファイルは同じ場所の Microsoft.PowerShell_profile.ps1
にあります。
PowerShell では、Linux の XDG ベース ディレクトリ仕様を尊重しています。
サポートされているバージョン
Microsoft では、PowerShell がサポート終了になるか、Alpine のバージョンがサポート終了になるまで PowerShell をサポートします。
x64 用の PowerShell 7.4 および PowerShell 7.5-preview を含む Docker イメージは、次のバージョンの Alpine のMicrosoft アーティファクト レジストリから入手できます。
- Alpine 3.20 - OS のサポートは 2026 年 4 月 1 日で終了
PowerShell の Docker イメージは、Alpine 3.21 では使用できません。
重要
Docker イメージは、OS ディストリビューターによって提供される公式のオペレーティング システム (OS) イメージから構築されます。 これらのイメージには、最新のセキュリティ更新プログラムがない可能性があります。 Microsoft では、最新のセキュリティ更新プログラムが確実に適用されるように、OS パッケージを最新バージョンに更新することをお勧めします。
インストールのサポート
Microsoft は、このドキュメントでインストール方法をサポートしています。 他のサードパーティのソースには、他のインストール方法を利用できる場合があります。 そのようなツールと方法は機能するかもしれませんが、Microsoft ではそれらの方法をサポートできません。
PowerShell