Logging into running container

GSA edited this page Mar 16, 2017 · 4 revisions

Ways to Login to Container

There are 2 primary ways to interactively login to container

  1. Use docker exec -it <containterID> powershell command like below. You don't need exact just a couple of letters from ID is enough. You can get ID of running container from "Get-Container" cmdlet.
PS C:\Users\admin> get-container

ID                   Image           Command              Created                Status               Names
--                   -----           -------              -------                ------               -----
41d3933032a1183e0... microsoft/iis   C:\ServiceMonitor... 1/19/2017 2:41:07 PM   Up 55 seconds        hungry_banach
PS C:\Users\admin> docker exec -it 41d powershell

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\> whoami
user manager\containeradministrator
  1. Login using Enter-PSSession cmdlet in following form Enter-PSSession -ContainerID <containerID> -RunAsAdministrator. To get you can use following shortcut if you know automatically assigned name (like hungry_banach above. You can see prompt changes to containerID once logged in.
PS C:\Users\admin> Enter-PSSession -ContainerId (Get-Container hungry_banach).ID -RunAsAdministrator
[41d3933032a1...]: PS C:\Users\ContainerAdministrator\Documents> whoami
user manager\containeradministrator
[41d3933032a1...]: PS C:\Users\ContainerAdministrator\Documents>

You can explore around the container to see what is there and what is missing

  • Container name which seems to be first 14 characters of containerID
[41d3933032a1...]: PS C:\> $env:ComputerName
  • Check who is member of administrators group. It is unsurprisingly Administrator account which is DISABLED. That means that you can NOT login to this computer remotely with ANY remote administrations tools. More on workarounds on this later.
[41d3933032a1...]: PS C:\> get-localgroupmember Administrators

ObjectClass Name                       PrincipalSource
----------- ----                       ---------------
User        41D3933032A1\Administrator Local

[41d3933032a1...]: PS C:\> get-localuser Administrator

Name          Enabled Description
----          ------- -----------
Administrator False   Built-in account for administering the computer/domain
  • Please note that Server service is not running and in fact it's impossible to start. This in addition of lack of username/password will prevent you from accessing file system in container or use remote administration tools
[41d3933032a1...]: PS C:\> get-service Server
Status   Name               DisplayName
------   ----               -----------
Stopped  LanmanServer       Server
  • Check ip configuration of container. You can see it's behind docker nat and points to internal NAT gateway. IP address is manually assigned to container (not DHCP by docker) along with other optional parameters which you can modify (like DNS)
[41d3933032a1...]: PS C:\> ipconfig

Windows IP Configuration

Ethernet adapter Ethernet 2:

   Connection-specific DNS Suffix  . : domain.com
   Link-local IPv6 Address . . . . . : fe80::ec1d:a23a:42d9:2fc5%5
   IPv4 Address. . . . . . . . . . . :
   Subnet Mask . . . . . . . . . . . :
   Default Gateway . . . . . . . . . :
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.