szahn
(Stuart Zahn)
July 13, 2017, 11:47pm
1
I need to get the process id of a dotnet application running in a windows container in order to attach a debugger to it, but when I try to list the processess, I get an empty list.
PS > docker exec -it --privileged elated_swartz powershell -Command Get-CimInstance Win32_Process | Select-Object ProcessId, CommandLine
ProcessId CommandLine
--------- -----------
PSVersion 5.1.15063.483
Docker Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:30:30 2017
OS/Arch: windows/amd64
Docker Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.24)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 22:19:00 2017
OS/Arch: windows/amd64
Experimental: true
friism
(Michael Friis)
July 13, 2017, 11:56pm
2
I think it’s better to use docker top
:
PS C:\WINDOWS\system32> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8448ffb7c15 microsoft/nanoserver "powershell -c sle..." 22 seconds ago Up 2 seconds romantic_leavitt
PS C:\WINDOWS\system32> docker top a8
Name PID CPU Private Working Set
smss.exe 868 00:00:00.734 217.1kB
csrss.exe 888 00:00:01.000 380.9kB
wininit.exe 932 00:00:00.156 655.4kB
services.exe 956 00:00:00.406 1.421MB
lsass.exe 976 00:00:00.937 2.781MB
svchost.exe 300 00:00:00.125 1.307MB
svchost.exe 588 00:00:00.171 1.356MB
svchost.exe 880 00:00:00.218 1.221MB
svchost.exe 1052 00:00:00.156 1.139MB
svchost.exe 1128 00:00:00.343 4.268MB
svchost.exe 1172 00:00:00.406 2.073MB
svchost.exe 1208 00:00:00.078 1.741MB
svchost.exe 1248 00:00:00.656 4.153MB
svchost.exe 1408 00:00:00.578 3.072MB
CExecSvc.exe 1424 00:00:00.062 819.2kB
powershell.exe 1556 00:00:05.421 16.64MB
szahn
(Stuart Zahn)
July 14, 2017, 12:38am
3
Is there a way to get the command line arguments per process? Windows does not support arguments to top
friism
(Michael Friis)
July 14, 2017, 1:27am
4
Hm, your command works fine for me:
docker exec a8 powershell -c "Get-CimInstance Win32_Process | Select-Object ProcessId, CommandLine"
ProcessId CommandLine
--------- -----------
0
4
868
888
932
956
976 C:\Windows\system32\lsass.exe
300 C:\Windows\system32\svchost.exe -k DcomLaunch
588 C:\Windows\system32\svchost.exe -k RPCSS
880 C:\Windows\system32\svchost.exe -k appmodel
1128 C:\Windows\System32\svchost.exe -k LocalServiceNetworkRestricted
1172 C:\Windows\system32\svchost.exe -k netsvcs
1208 C:\Windows\system32\svchost.exe -k LocalService
1248 C:\Windows\system32\svchost.exe -k NetworkService
1408 C:\Windows\System32\svchost.exe -k utcsvc
1424 C:\Windows\system32\cexecsvc.exe
1556 powershell -c sleep 3600
492 C:\Windows\system32\wbem\wmiprvse.exe
468 powershell -c "Get-CimInstance Win32_Process | Select-Object Proce...