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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
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