-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Within a dev container using Docker 26, vite dev
or vite preview
cannot be accessed from the host
#16522
Comments
I had this same issue, there is a note about a windows container bug in the Docker release notes. They suggest using a But, the solution that worked for me was to run it with the
However, I am only able to connect via the first, localhost option (either EDIT: This issues seems only related to vite. When using another Docker dev Container, which exposes port 8282 to the host in a none vite environment, I am able to connect to the server correctly. Running vite with This can also be achieved by editing the server: {
port: 8002,
host: '127.0.0.1'
} I think that vite needs to change behaviour to use as default |
Vite currently isn't working in a Docker environment for development following along here: vitejs/vite#16522 Going to commit these files as placeholders, and probably still containerize the backend/db together even if I can't get Nuxt in there yet.
Could this be related to ipv4 and ipv6? The |
I just tried this, but was unable to connect over ipv6 via In my particular scenario, setting |
I tried this because I've tried upgrading and downgrading everything and nothing has worked this after I had rebuilt my dev container and these steps have not resolved my issue... |
Seems to do the trick for me. Having Vite using |
It seems docker v26 started to return |
Yes, using Again, I still think that setting |
This is it! I thought It was a DevContainer thing, but it was actually a Docker one. My current docker version: |
I had a similar problem. Interestingly this option did not seem to work:
|
I ran into this problem as well with Windows 11 and Docker 25 (not 26 as discussed above). The fix's mentioned above worked for me. |
Run into this problem today. Windows 11 , Docker 26 WSL2. I changed the configuration file to this:
and it worked. |
Can this be affected by proxy? I tried pretty much all of the above and still I can't access vite server from my host. LE: it was due to .wslconfig in my userprofile that had mirroredNetwork option active. |
See below for more information vitejs/vite#16522
I wonder if that is the case because I spun up a docker container with a Dockerfile (no Dev Container) with Vite and it worked. The problem seems to appear only when I use Dev Container with Vite. But, by the way, both |
I've set the |
Any plan about fixing it ? I just tested it again, and it still seems to be broken on docker@latest + node@latest and docker@latest + deno@latest |
What do we need to fix? Vite defaults to This seems more like a necessary configuration if you use Docker v26 with how the default works now as explained in #16522 (comment) |
What would it get for it to "just work™" with no option added ? Would it be a patch in Docker ? Otherwise, would there be a way for vite to introduce a Currently, Vite dev doesn't work OOTB in devcontainers, which is arguably suboptimal |
That'll mean Vite hardcoding special handling for Docker, which I don't think it should do. It has to start accounting for different docker versions and configurations, which is a can of worms. The other option is to not have Docker misalign on the ipv4 and ipv6 settings, but from what I understand it was an intentional decision. So from both ends, there isn't really a reasonable fix here. Maybe I miss a general heuristic Vite could use which you can point out on? |
Nope I also do not have any idea on how to enhance the situation I am simply considering it quite painful for all Vite + |
To be honest, I don't think this is necessarily a docker/vite problem. As I said in my comment above, the issue only happens when using docker, vite and Dev Container. When I tried docker and vite, that is, without dev container, it worked as before. |
Workarounds
Which is the "best" to use ? |
Thanks @fprotazio, I fixed my comment |
If specifically devcontainers, I think my points above still stands. If neither side is changing the behaviour to make this work ootb, we could fallback to documentation. |
Probably VSCode's port forwarding feature needs to support IPv6. |
Absolutely. I was just trying to clarify even further |
Let's perhaps document this at https://vite.dev/guide/troubleshooting.html#others then and link to the github issue sapphi sent above to follow the progress. |
This is a good idea indeed I mentioned this problem in the issue : microsoft/vscode-remote-release#7029 (comment) By the way, can someone please kindly answer this question: |
I think |
For me the following was preferred to the other workarounds: Added export default {
server: {
host: true
}
} |
Adding the following to my sysctls:
net.ipv6.conf.all.disable_ipv6: 0
net.ipv6.conf.all.forwarding: 1 |
Describe the bug
I initialy though this was a case of #11468 (comment), but it seems it is something else, so I am opening another issue.
Using Dev Containers for development, and after upgrading to Docker 26 (from 25) on the host, I am unable to connect to either
vite dev
orvite preview
server using the default and basic port forwarding feature of the dev containers.By "unable to connect", I mean that the server is launched, however when trying to connect from my host using
http://localhost:4200/
, either Chromium or Firefox Dev Edition request hangs indefinitely on loading (it stays in loading state without timing out for at least for a good 5-10 minutes; didn't test longer than that).I am using Nx, but using vite directly does not change the outcome.
For the recoard, I also have a
dotnet
server that is responding as expected to the request, so for now (in my limited available code base), this point out tovite
, but it may well be due to whichever node server backend vite is using.Reproduction
unable to provide without control of the host docker version
Steps to reproduce
No response
System Info
Dev Container
I am using a custom pre-built image, which is a copy of
mcr.microsoft.com/devcontainers/typescript-node:20
Host
docker-ce-cli (5:26.1.0-1~ubuntu.22.04~jammy)
docker-ce (5:26.1.0-1~ubuntu.22.04~jammy)
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: