Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active September 19, 2020 09:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/cb994571db1fc6e79f997eedef39224f to your computer and use it in GitHub Desktop.
Save guitarrapc/cb994571db1fc6e79f997eedef39224f to your computer and use it in GitHub Desktop.
Get Process by port
docker run -it --rm -p 8080:80 nginx:latest
$port = 8080
(Get-NetTCPConnection -LocalPort $port -State Listen).OwningProcess | %{Get-Process -Id $_}
# RESULT
# Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
# ------- ------ ----- ----- ------ -- -- -----------
# 202 29 1580 5432 0.02 18228 1 wslhost
# 307 38 22840 22220 3.58 17372 1 com.docker.backend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment