LoginSignup
4
2

More than 5 years have passed since last update.

Docker + CentOSでpowershell実行環境簡単構築

Last updated at Posted at 2018-11-21

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

最後に

ふと思いたち、とても簡単にできました。。。が、これ需要あります?(笑)

参考サイト

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2