DockerにCentOS入れて、CentOS上にPowerShell for Linux をインストールして、Linux上でpowershellが使用できるようにしていきます。
環境
Mac 10.13.6
Docker version 18.06.0-ce, build 0ffa825
docker-compose version 1.22.0, build f46880f
PSVersion 6.1.1
構成
構成は非常にシンプルです。
.
├── docker
│ └── powershell
│ └── Dockerfile
└── docker-compose.yml
構築
docker-dompose.yml
シンプルにcentos用のコンテナのみ構築する想定です。
※ tty=trueにしておかないとdockerが起動し続けてくれないので注意
docker-compose.yml
version: '3'
services:
app:
container_name: powershell
build: ./docker/powershell
tty: true
Dockerfile
centOS7の公式イメージを取得します。そして、PowerShell for Linuxをインストールします。
Dockerfile
FROM centos:7
RUN curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo
RUN yum -y install powershell
コマンド
docker起動
docker-compose up -d
コンテナに入る
docker-compose exec app /bin/bash
powershell起動
pwsh
powershellコマンドレット一覧表示
Get-Command
powershellコマンドレット一覧表示
$PSVersionTable
powershell終了
exit
コンテナから出る
exit
最後に
ふと思いたち、とても簡単にできました。。。が、これ需要あります?(笑)