vitejs/vite

Vite does not open the browser in Docker environment

scriptPilot opened this issue · 2 comments

Describe the bug

I would like to run both, backend and frontend in Docker.

Vite should open the server in the browser automatically.

Running directly it works like a charm.

Running in Docker environment it fails to open the browser on the local device.

Reproduction

https://github.com/scriptPilot/bug-vite-open

Steps to reproduce

see README in repo

System Info

see Docker in repo

Used Package Manager

npm

Logs

No response

Validations

I don't think this is possible to do it out-of-the-box.

To open the browser on the host machine from Vite running in docker, Vite will somehow need to execute a script on the host machine side. But that needs to be explicitly allowed when running the container and Vite cannot control how the container is started.

Thanks for the explanation. As a workaround / solution I open the browser before with a dedicated command:

... open http://localhost:5173 && docker exec -it node npx vite --host