search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell, Windows Server | No Comment | 1,908 views | 04/10/2015 20:22

Windows Containers are finally here! Lets start our new series :)

Container management is very similar to Hyper-V management. For example:

container

Lets check our commands:

PS C:\Users\Administrator> get-command *container*
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Install-ContainerOSImage                           1.0.0.0    Containers
Function        Uninstall-ContainerOSImage                         1.0.0.0    Containers
Cmdlet          Add-ContainerNetworkAdapter                        1.0.0.0    Containers
Cmdlet          Connect-ContainerNetworkAdapter                    1.0.0.0    Containers
Cmdlet          Disconnect-ContainerNetworkAdapter                 1.0.0.0    Containers
Cmdlet          Export-ContainerImage                              1.0.0.0    Containers
Cmdlet          Get-Container                                      1.0.0.0    Containers
Cmdlet          Get-ContainerHost                                  1.0.0.0    Containers
Cmdlet          Get-ContainerImage                                 1.0.0.0    Containers
Cmdlet          Get-ContainerNetworkAdapter                        1.0.0.0    Containers
Cmdlet          Import-ContainerImage                              1.0.0.0    Containers
Cmdlet          Move-ContainerImageRepository                      1.0.0.0    Containers
Cmdlet          New-Container                                      1.0.0.0    Containers
Cmdlet          New-ContainerImage                                 1.0.0.0    Containers
Cmdlet          Remove-Container                                   1.0.0.0    Containers
Cmdlet          Remove-ContainerImage                              1.0.0.0    Containers
Cmdlet          Remove-ContainerNetworkAdapter                     1.0.0.0    Containers
Cmdlet          Set-ContainerNetworkAdapter                        1.0.0.0    Containers
Cmdlet          Start-Container                                    1.0.0.0    Containers
Cmdlet          Stop-Container                                     1.0.0.0    Containers
Cmdlet          Test-ContainerImage                                1.0.0.0    Containers

I can create a new container with following command:

New-Container -Name "MyContainer" -ContainerImageName WindowsServerCore -SwitchName "Virtual Switch"

If you install Windows Containers with Microsoft Documentation, then you should have a virtual switch called “Virtual Switch” in your environment.

New-Container accepts many parameters:

NAME
    New-Container
 
SYNTAX
    New-Container [[-Name] <string>] -ContainerImageName <string> [-ContainerImagePublisher <string>]
    [-ContainerImageVersion <version>] [-CimSession <CimSession[]>] [-ComputerName <string[]>] [-Credential
    <pscredential[]>] [-MemoryStartupBytes <long>] [-SwitchName <string>] [-Path <string>] [-AsJob] [-WhatIf]
    [-Confirm]  [<CommonParameters>]
 
    New-Container [[-Name] <string>] -ContainerImage <ContainerImage> [-MemoryStartupBytes <long>] [-SwitchName
    <string>] [-Path <string>] [-AsJob] [-WhatIf] [-Confirm]  [<CommonParameters>]

There is a parameter called “MemoryStartupBytes” but it seems it just changes startup memory. It seems there is no memory or processor limit yet.

container2

Starting Container is similar like Hyper-V VMs:

Start-Container -Name "MyContainer"

After start your container, you should configure your Host’s Firewall because Container uses Host Firewall. If you try to configure firewall inside Container, you will get warning.

You can use Enter-PSSession like in Hyper-V VMs to connect Container:

Enter-PSSession -ContainerId (Get-Container MyContainer).ContainerId -RunAsAdministrator

You can disable firewall with following command to test RDP connection:

Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

After that, you may have to enable Administrator account in Container with:

net use administrator /active:yes
net use administrator Password1!

See you in next part!