1

I've dockerized vue.js app running on localhost:8090 on a VM server. I've connected that VM server to my VS Code using SSH and was able to access the vue.js app on my local machine's chrome browser after port forwarding. But in the same VM, there's another selenium python dockerized project which does automated testing of the vue.js app so it needs to access the localhost:8090 URL. when the Vue.js app server is up. Unfortunately, the python selenium project isn't able to get and request the localhost:8090 URL. I've increased sleep time in selenium tests and also added implicit or dynamic(webdriverwaits) but still won't work.

It would be a +1 if someone can suggest how to open localhost:8090 in VM vscode without port forwarding.

This is the error I'm receiving after adding webdriverwaits implicit waits

petezurich
  • 9,280
  • 9
  • 43
  • 57

2 Answers2

2

You have three options:

  • You can access VueJS App on http://host.docker.internal:8090 from testing container. to access port from host machine. you need to use host.docker.internal as DNS route name.
  • You can assign container name to VueJS container. and use http://{VueJS Container Name}:80 you can add container name in run with ththis param --name {Container-Name}
  • You can use Docker-Compose.
  • [https://docs.docker.com/desktop/mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host](https://docs.docker.com/desktop/mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host) Above is a ref link, where docker docs has a example of using host machine port `8000` from another docker container – Shakir Fattani May 28 '22 at 07:58
  • 1
    Thanks for the suggestion it worked when I used the http://{VueJS Container Name}:80 approach with passing --network host or (you can try creating a new network and pass that network name in --network flag) flag in both containers run commands. – Raheel Siddiqui May 29 '22 at 15:35
0

run both Vue.js and Selenium containers with docker run --network=host

soanni
  • 1
  • I have a different server running on the default 8080 port on VM that is why it gives me warning *WARNING: Published ports are discarded when using host network mode* Is there any way it can be published on 8090 port? – Raheel Siddiqui May 27 '22 at 19:33