Skip to content
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.5.1(74721): docker context ls gives invalid character '\x00' looking for beginning of value` #12561

Closed
3 tasks done
yilmazdurmaz opened this issue Feb 16, 2022 · 17 comments
Closed
3 tasks done

Comments

@yilmazdurmaz
Copy link

yilmazdurmaz commented Feb 16, 2022

TLDR: I have found out that some contexts' "meta.json" files under "~/.docker/contexts/*" were broken (all zeros inside) after the update for a reason. I don't know why it happens so can't say if it is avoidable. Removing these broken context files/folders seems to fix it, but since it involves deleting things do it cautiously.


  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID: F4DF3B90-85B1-4ADA-A649-632567964988/20220216104026

Actual behavior

I use VSCode to work within containers. I got 2 updates recently; the previous one seemingly had no problem on me with WSL2, but I decided to update to the latest, 74721, because your update notes were telling me there were problems with that.

Now after the update, my containers are running but trying to get the list in VSCode docker extension, it fails to connect to docker. From the error I got, I tried docker context ls on a separate terminal and got this response: invalid character '\x00' looking for beginning of value

Expected behavior

Information

I don't know if this can be reproducible, but the problem is new, at least for me. And yes problem started with this latest update, also I don't use any experimental features. I have stopped both WSL2's LxssManager ad let docker restart it, and also shutdown docker and restarted it. None solved the problem.

  • Windows Version: 10 Pro 21H2
  • Docker Desktop Version: v4.5.1(74721)
  • WSL2 or Hyper-V backend? WSL2 (or at least I did not activate any Hyper-V myself)
  • Are you running inside a virtualized Windows e.g. on a cloud server or a VM: NO

Output of & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

[047:13:58:51.101][I] ipc.NewClient: 5c156424-com.docker.diagnose -> \\.\pipe\dockerBackendV2 com.docker.service.exe
[goroutine 1 [running, locked to thread]:
[win/backend/pkg/service.NewClientForPath(...)
[       win/backend/pkg/service/service.go:42
[win/backend/pkg/service.NewClient({0x15ef112, 0x13}, {0x0, 0x0, 0x0})
[       win/backend/pkg/service/service.go:31 +0xd0
[common/pkg/diagkit/gather/diagnose.init()
[       common/pkg/diagkit/gather/diagnose/ipc_windows.go:23 +0x11f
Starting diagnostics

[PASS] DD0027: is there available disk space on the host?
[PASS] DD0028: is there available VM disk space?
[PASS] DD0031: does the Docker API work?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0001: is the application running?
[SKIP] DD0018: does the host support virtualization?
[PASS] DD0002: does the bootloader have virtualization enabled?
[PASS] DD0017: can a VM be started?
[PASS] DD0024: is WSL installed?
[PASS] DD0021: is the WSL 2 Windows Feature enabled?
[PASS] DD0022: is the Virtual Machine Platform Windows Feature enabled?
[PASS] DD0025: are WSL distros installed?
[PASS] DD0026: is the WSL LxssManager service running?
[PASS] DD0029: is the WSL 2 Linux filesystem corrupt?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0003: is the Docker CLI working?
[PASS] DD0013: is the $PATH ok?
[PASS] DD0005: is the user in the docker-users group?
[PASS] DD0007: is the backend responding?
[PASS] DD0014: are the backend processes running?
[PASS] DD0008: is the native API responding?
[PASS] DD0009: is the vpnkit API responding?
[PASS] DD0010: is the Docker API proxy responding?
[PASS] DD0006: is the Docker Desktop Service responding?
[PASS] DD0012: is the VM networking working?
[PASS] DD0032: do Docker networks overlap with host IPs?
[SKIP] DD0030: is the image access management authorized?
[PASS] DD0033: does the host have Internet access?
No fatal errors detected.

Steps to reproduce the behavior

I don't know how to reproduce this. All I can say is this:

  1. I installed docker 1-2 months ago
  2. Since then I had 2 or 3 updates.
  3. This last update has this problem with it.
@yilmazdurmaz
Copy link
Author

I had tried creating new contexts and also installed all versions back to 4.3.2.

I thought one of them would be viable since I had another update during that time. Yet the problem persisted.

Thinking it would solve, I have also created new contexts. Again, the problem persisted.

I have then found out that this update has broken one of my context files; to be specific, it emptied the content of a meta.json by writing all zeros in it. Thus none of the downgrade attempts could succeed.

I did not create any specific contexts manually before. So this file should be one of the "default" contexts from previous updates. The folder this file resides in has a creation timestamp of "12 Dec 2021", and the file itself has the same creation but a modified timestamp of "15 Feb 2022", the time I have updated the program.

Deleting this file/folder fixes this issue, but the truth that this file got broken remains. Please check the update/install process and fix this issue as it can easily happen again anytime.

And also it would be a better idea to give a "context file is broken" message if this error happens.

PS: I now removed my ~/.docker folder as I don't have a sophisticated environment and reinstalled 4.5.1. It now works without any extra setup.

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@kompolom
Copy link

kompolom commented May 27, 2022

We have to remove just ~/.docker/contexts and restart docker daemon to fix it.

@yilmazdurmaz
Copy link
Author

We have to remove just ~/.docker/contexts and restart docker daemon to fix it.

Only if there is no specially made context in it.

Else one needs to dig in, find corrupted context(s), remove only those that are not important, and replace others if there is a backup of them.

corrupted context files have all content replaced by null bytes: "hello" becomes "\x00\x00\x00\x00\x00" hence the "\x00" error. A hex viewer will help to see this binary content.

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jul 26, 2022
@milas
Copy link

milas commented Nov 7, 2022

Reopening, as we've gotten recent reports of Compose users hitting this - see docker/compose#9956.

@krave1986
Copy link

I have the same issue too. I thought that would be an issue related with VS Code. So I opened up an issue over there. I didn't use Compose but Dockerfile only.

@yilmazdurmaz
Copy link
Author

Hi @milas, does this problem come up only on Windows, or have you met it on other OSs? It seems to occur during updates but does not follow a strict occurrence pattern.

I believe the docker setup does not create any contexts, and it is the docker executable/service that is responsible to create them when it first starts and just tries to use them afterward. Then this should be a problem of tracing when/how it closes the file handler to these context files when it goes down (version update or machine restart).

@stoooops
Copy link

stoooops commented Feb 1, 2023

I am facing this issue trying to build docker containers via compose on WSL.

I arrived here via this link docker/compose#9956

version: '3'

services:
  api:
    container_name: api
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/app
    working_dir: /app
    command: python -m python.server
    ports:
      - '5000:5000'

I get this error

$ docker compose up
docker endpoint for "default" not found

@yilmazdurmaz
Copy link
Author

@stoooops , please try to read the solving comments and "TLDR" sections (when present) before adding up to the pile of complaints.
run this command: docker context ls. if you get the error \x00 as in the title, that means you are on the same train and you need to read a bit carefully to remove broken contexts. if you are getting a different error, please report it in your original bug discussion

@stoooops
Copy link

stoooops commented Feb 2, 2023

I had read everything thank you very much for assuming I can't read.

The issue persists. Please let me know what debug information you are looking for. I gave you the exact file and command.

It works after reboot.

@yilmazdurmaz
Copy link
Author

yilmazdurmaz commented Feb 2, 2023

please do not fight. obviously, you do not read as attentively as you think.

  • run docker context ls
  • if you get invalid character '\x00' looking for beginning of value error, then read again: docker contexts are broken.
  • IF NOT, this is not the place you should be writing. move back to your original issue post and report there that you do not have this error.

@yilmazdurmaz
Copy link
Author

Hi again @milas,

I was doing some thinkering with contexts and found out that \x00 and JSON errors might not have the same underlying bug.

I created a new context and tried to place \x00 inside the meta.json. These are the errors for having a single \x00 at different locations.

invalid character '\x00' looking for beginning of value
invalid character '\x00' looking for beginning of object key string
invalid character '\x00' in string literal
invalid character '\x00' after top-level value

In the error I reported here, each and every character of the meta.json file is fully replaced by this null character.

However, I could generate unexpected end of JSON input error only when the file context is not in the format expected by JSON parser. two examples of it are having a completely blank file and removing the curly brace at the end.

Of course, both situations means at least one context is broken (and removal of them fixes the problem), but I believe it is not fair to just redirect other bug discussions of this second type here. (also some users report the second case reanimates itself after a reboot)

I suggest opening a new discussion to follow them together as they both are related to docker contexts, but also summarize these little details. for example, whatever the reason is, if someone with a broken context tries to run docker compose with a build instruction, they get this nasty docker endpoint for "default" not found message. we may ask these people to use docker context ls first to make sure it is a context problem.

PS: @stoooops, I am sorry if you are confused and offended by my previous message. with this, you can see there many error messages coming up when the context is broken, and also many answers leading to the removal of context folder. just do not forget to be extra careful since you are deleting things from your computer.

nicks added a commit to nicks/cli that referenced this issue Feb 21, 2023
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 <[email protected]>
nicks added a commit to nicks/cli that referenced this issue Feb 21, 2023
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 <[email protected]>
nicks added a commit to nicks/cli that referenced this issue Feb 21, 2023
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 <[email protected]>
@chaizeg
Copy link

chaizeg commented Feb 27, 2023

Closing this issue because a fix has been released in Docker Desktop 4.17.0 . See the release notes for more details.

@chaizeg chaizeg closed this as completed Feb 27, 2023
@yilmazdurmaz
Copy link
Author

Hi @chaizeg, This is something great to hear.

There is a small typo I should note: That release notes page shows the release date for version 4.17.0 as "2022-02-27". A small date typo. For a moment, I thought I was reading some old page :)

@chaizeg
Copy link

chaizeg commented Feb 27, 2023

Thank you @yilmazdurmaz, should be rectified now!

thaJeztah pushed a commit to thaJeztah/cli that referenced this issue Mar 1, 2023
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 <[email protected]>
(cherry picked from commit c2487c2)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

/lifecycle locked

craig-osterhout pushed a commit to craig-osterhout/cli that referenced this issue Apr 21, 2023
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants