LoginSignup
1
0

More than 3 years have passed since last update.

[メモ] Windows2019でWindowsコンテナ+Dockerにて、IIS

Posted at

ここ↓で公開されている box イメージの Windows Server 2019(英語)の180日評価版を使って、Windows Containerを使ってみる。

環境

  • ホスト機:
    • Windows 10 Pro 64bit
    • VirtualBox v6.0.8
    • Vagrant v2.2.4

手順

ホスト機

  1. 左下のWindowsのアイコンを右クリックして、PowerShellを管理者で開く
  2. Chocolatey導入して、Virtualbox と vagrantをインストール

    コピペ(管理者で)
    # Chocolatey導入
    Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
    #
    # virtualboxとvagrantのインストール
    cinst -y virtualbox vagrant
    
  3. Windows Server 2019の仮想機
    vagrant upで、初回、6GB近いイメージをダウンロード・展開して、VMを起動するので、1時間くらいかかる

    mkdir C:\vagrant\WinSvr2019
    cd C:\vagrant\WinSvr2019
    vagrant init -m StefanScherer/windows_2019
    # Vagrantfileが生成されるので、↓のように編集する
    notepad Vagrantfile
    #
    vagrant up ; vagrant reload
    
    Vagrantfileを編集
    Vagrant.configure("2") do |config|
      config.vm.box = "StefanScherer/windows_2019"
      config.vm.network :forwarded_port, host: 23389, guest: 3389, id:"rdp", auto_correct: true  # <= この行を追加
    end
    
  4. 以下のようなエラーがでるが、気にせず、vagrant reload で再起動

    .
    .
    .
        default: WinRM transport: negotiate
    An error occurred executing a remote WinRM command.
    
    Shell: Cmd
    Command: hostname
    Message: [WSMAN ERROR CODE: 2147942421]: <f:WSManFault Code='2147942421' Machine='127.0.0.1' xmlns:f='http://schemas.microsoft.com/wbem/wsman/1/wsmanfault'><f:Message><f:ProviderFault path='%systemroot%\system32\winrscmd.dll' provider='Shell cmd plugin'>The device is not ready. </f:ProviderFault></f:Message></f:WSManFault>
    PS C:\vagrant\WinSvr2019>
    
  5. vagrant rdp で、リモートデスクトップ接続
    ユーザ vagrant パスワード vagrant でログイン

Windows Server 2019 VMにて

  1. こんな感じで、管理者で、PowerShellを開く

    image.png

  2. Dockerインストール
    以下コピペ。途中、Y と入力するところがある。

    以下コピペ
    Install-WindowsFeature -Name Containers;Install-Module -Name DockerMsftProvider -Repository PSGallery -Force ; Install-Package Docker -ProviderName DockerMsftProvider -Force
    

    image.png

  3. リモートデスクトップを閉じて、vagrant reload でVirtualBoxのWinSvr2019を再起動

  4. docker run hello-world

    image.png

IIS

PowerShellにて
mkdir C:\inetpub\wwwroot
cd C:\inetpub
echo "Hello IIS !" > C:\inetpub\wwwroot\index.html
icacls C:\inetpub\wwwroot /grant Everyone:F

# イメージ起動
docker run -d --rm --name iis -p 8080:80 -v C:\inetpub\wwwroot:C:\inetpub\wwwroot microsoft/iis

# Internet Explorerにて、アクセス
'C:\Program Files\internet explorer\iexplore.exe' http://localhost:8080/
  • WinSvr2019に付属の Internet Explorerにて
    image.png

その他

  • vagrant destroy して、vagrant upすると、評価期間が180日に戻っている?
1
0
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
1
0