-
Notifications
You must be signed in to change notification settings - Fork 289
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
v4.16.2: docker context list
gets "unexpected end of JSON input"
#13180
Comments
|
And reverting to v4.15.0 I still have this problem, so I imagine it's some file left as-is during uninstall? Tried removing .docker/config.json but that didn't help. |
I did find a 4.16.1 (that was updated from a previous version) that does not show this behavior. These two that are failing are fresh installs. |
Now this is happening on a 3rd machine running 4.16.1, and I have no solutions. |
Under the hood, I think 'docker context ls' reads json files on disk, decodes them, and pretty prints them. It doesn't change much. I doubt it changed between 4.15 and 4.16. I think the files are under ~/.docker/contexts or something similar? Probably they're getting corrupted somehow by some command that runs before. Maybe there's a docker/cli bug here to print the file where the error is coming from. |
Thanks @nicks - Here's what I saw:
On each system there was a meta.json that was empty. Deleting them made On each of two Windows/WSL2 systems I examined, the contexts were zeroed out/corrupted, and this was true both inside wsl2 in ~/.docker/contexts and also on PowerShell in ~/.docker/contexts. I imagine something in 4.16.1 is zeroing them out, not sure. |
This problem continues in 4.16.2 without change. I find that if I remove the |
docker context list
gets "unexpected end of JSON input"docker context list
gets "unexpected end of JSON input"
possibly related - #12561 (though the exact symptoms are slightly different) |
Thanks - these context files seem to be empty, so I think although the symptom is the same, the cause may be different. |
so i got this problem too, using Docker Desktop for Windows version 4.16.2 (95914). the only fix i can do is using docker/desktop-linux#57 (comment) solution.
unfortunately, when i restart my docker desktop, the context got cleared again. and i need to do this all over again. |
Clarification question @rfay : after you delete the directory, how long does it take to re-occur? On every desktop restart? After a few hours? Intermittently? |
I am also facing this problem. I've created a dummy context. I get the issue less often, but it still occurs. Before I would just delete the hash folder with the empty meta.json, then the problem would come back a lot quicker (I recon docker doesn't like when your meta folder is empty). It seems to occur when I crash my docker, it sometimes happens when I've restarted my PC. Haven't really noticed a distinct pattern yet. The hash with the empty meta.json always seems to have the same hash, maybe that might give some clues. |
sorry to interrupt, i finally fixed it by deleting my NOTE: i'm not "deleting" it perse, just rename it to |
Do you mean .docker folder? I don't seem to have a .docker file |
yeah the .docker folder. |
Deleting ~/.docker would fix it certainly until the next Docker Desktop restart. Same as deleting ~/.docker/contexts |
@nicks if you delete ~/.docker/contexts it solves this problem until the next Docker Desktop restart, when the empty context json file immediately reappears and breaks |
Deleting ~/.docker/contexts works for me too. How can this be fixed ASAP @thaJeztah ? Do we need to create a ticket at moby too? |
The On Docker Desktop, its possible that other binaries interact with those files, e.g. the compose-cli wrapper (used for cloud integration) may also be interacting with them; https://github.com/docker/compose-cli/blob/7a57a330f6d94247e36dc868b3d9d7161fb4429f/api/context/store/store.go#L81-L97 Not sure when/in what cases it would though. |
Thanks for looking at this @thaJeztah - Since restarting Docker Desktop (and not doing anything else) creates the empty context json files, it seems to implicate some kind of interaction. |
Thanks for the feedback @thaJeztah |
At this moment it's not 100% clear where the cause is (so it could be fully unrelated to the CLI code). Maybe @nicks has done more digging into the issue though (from the Docker Desktop side of things). |
We were talking about it because we saw a slight uptick of complaints about it in the compose repo. Haven't been able to repro it, and the reports are kind of all over the place repro-wise (a couple reports that it happens on every desktop restart, other reports that say it's intermittent, other reports about it from years ago, etc etc.). And not so many reports to make me think a large percentage of users are seeing it. Stumped. One thing that's slightly suspicious is that the diagnostic bundle rfay posted above has a timestamp of when the meta.json file was written with empty contents, but the desktop logs from that time are mysteriously missing. But this might be a red herring. |
That's odd, I can't find On buildx we are vendoring docker cli 23, that might be why: https://github.com/docker/buildx/blob/cb94298a0238f67e008658e831af8b8dd313d444/go.mod#L10 I have no clue why compose users would have this issue though: https://github.com/docker/compose/blob/f24d3458c6d05e19519e660e4faa04d47f6db103/go.mod#L14 But best guess is cli vendored in buildx messed up the context store and therefore impacts compose after that. |
@crazy-max compose also has a replace rule https://github.com/docker/compose/blob/f24d3458c6d05e19519e660e4faa04d47f6db103/go.mod#L159 |
@thaJeztah Could be linked to docker/cli#3790? |
@nicks docker/compose#9956 ? |
@bplasmeijer ya, it's helpful to have logs of the sequence:
or you could try the debug build in #13180 (comment) and see if it still re-corrupts the file. |
Is this safe to use though? |
i've been running into this issue for weeks, also on WSL2, it's been a giant pain, especially when trying to boot up dev containers. I will give a go at trying that build! let me know if i can provide any helpful logs. |
That debug build didn't work, i'm still getting blank generated |
I was previously only attempting to clear context via clearing the .docker/contexts folder on the WSL side, but hadn't thought to check out the Windows side until i saw that comment upthread. On a hunch I erased the newline at the end of the meta.json on the Windows side, and I think that's fixed the issue? 🙏 I can do a full docker restart with no corruption to the contexts! |
all delete |
ok, i have a sandbox that reliably reproduces this, it's here: i think there are multiple levels of safety checks in docker/cli and docker/for-win that will help mitigate this, but the sandbox will help me test them. |
I hit this problem today. If it helps, here is a recap of my activity. Maybe there is something different between the dev container "Create Dev Container" and the open using the local .devcontainer directory. |
@DenyWatanabe thanks your solution worked for me. I'm on W11 using WSL and the meta.json under my windows profile .docker folder
EDIT: Docker Desktop 4.16.3 (96739) |
hi! I hope my solution helps someone. From the WSL console, inside ~/.docker: Those two symlinks shown above were broken, so I releted them and recreated them, then applied the change that @alchatti suggested and restarted docker. Hope it helps! |
Write to a tempfile then move, so that if the process dies mid-write it doesn't corrupt the store. Also improve error messaging so that if a file does get corrupted, the user has some hope of figuring out which file is broken. For background, see: docker/for-win#13180 docker/for-win#12561 For a repro case, see: https://github.com/nicks/contextstore-sandbox Signed-off-by: Nick Santos <nick.santos@docker.com>
Write to a tempfile then move, so that if the process dies mid-write it doesn't corrupt the store. Also improve error messaging so that if a file does get corrupted, the user has some hope of figuring out which file is broken. For background, see: docker/for-win#13180 docker/for-win#12561 For a repro case, see: https://github.com/nicks/contextstore-sandbox Signed-off-by: Nick Santos <nick.santos@docker.com>
Write to a tempfile then move, so that if the process dies mid-write it doesn't corrupt the store. Also improve error messaging so that if a file does get corrupted, the user has some hope of figuring out which file is broken. For background, see: docker/for-win#13180 docker/for-win#12561 For a repro case, see: https://github.com/nicks/contextstore-sandbox Signed-off-by: Nick Santos <nick.santos@docker.com>
thanks man |
Hi there. Only deleting the folder %USERPROFILE%.docker\contexts\meta on Windows side solves the problem even after restart the docker desktop. |
I delete .docker, close IDE, off docker-desktop, --wsl shutdown, restart PC, and now all works and now i dont need reopen meta file. |
Closing this issue because a fix has been released in Docker Desktop |
Write to a tempfile then move, so that if the process dies mid-write it doesn't corrupt the store. Also improve error messaging so that if a file does get corrupted, the user has some hope of figuring out which file is broken. For background, see: docker/for-win#13180 docker/for-win#12561 For a repro case, see: https://github.com/nicks/contextstore-sandbox Signed-off-by: Nick Santos <nick.santos@docker.com> (cherry picked from commit c2487c2) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. /lifecycle locked |
Write to a tempfile then move, so that if the process dies mid-write it doesn't corrupt the store. Also improve error messaging so that if a file does get corrupted, the user has some hope of figuring out which file is broken. For background, see: docker/for-win#13180 docker/for-win#12561 For a repro case, see: https://github.com/nicks/contextstore-sandbox Signed-off-by: Nick Santos <nick.santos@docker.com>
Actual behavior
PS C:\Users\testbot> docker context list
unexpected end of JSON input
Expected behavior
docker context list
should give a list of docker contextsThis happens in PS and in WSL2 as well, same thing. I tested on two different Windows systems.
I tested on macOS and did not see this.
Information
Output of
& "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check
Skipped since I haven't ever seen it work
Steps to reproduce the behavior
On 4.16.1,
docker context list
The text was updated successfully, but these errors were encountered: