Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does VSCode [Remote Development] [Forward Port] work?

When using VSCode Remote Development Open Folder in Container to develop in docker container in Mac, I can not find:

  • Any info about the port by docker inspect containerId
  • Any port config in Dockerfile

But I can still access the service in container from host browser.

like image 459
vikyd Avatar asked Feb 23 '26 04:02

vikyd


1 Answers

VS Code uses SSH Tunnel to connect to remote machine. The port forwarding is simply creating this tunnel. You can do it without vscode with the command below if you have ssh client installed. You have to run this command from localhost shell prompt. (I assumed we want to connect to port 8080 on remote-machine using localhost:8085)

ssh -L 8085:remote-machine-ip:8080 remote-machine-ip

Now, from your browser, if you go to http://localhost:8085 it will show content from remote-machine's 8080 service

like image 50
hasan.in Avatar answered Feb 25 '26 21:02

hasan.in



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!