compose: [BUG] docker endpoint for "default" not found

Description

when building Dockefile with docker compose

docker compose build

got this error docker endpoint for “default” not found but if i try to build with a remote docker image compose works fine.

github repo: https://github.com/milon27/hello-docker.git

Steps To Reproduce

  1. clone this repo https://github.com/milon27/hello-docker.git
  2. run docker compose up
  3. you should get docker endpoint for “default” not found this error

os: windows 10 docker desktop version: 4.13.0

note: it was fine when I update the docker desktop to the latest version this problem started.

Compose Version

Docker Compose version v2.12.0

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.12.0)
  dev: Docker Dev Environments (Docker Inc., v0.0.3)
  extension: Manages Docker extensions (Docker Inc., v0.2.13)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.20
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.16.3-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 12.39GiB
 Name: docker-desktop
 ID: P4Q6:4LDD:2OTW:O7QR:GYH5:4O4W:BHM6:XK5R:33DQ:AYA5:SMX7:WBHK
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Anything else?

Error screenshot

image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 66 (5 by maintainers)

Most upvoted comments

docker context ls returns:

invalid character '\x00' looking for beginning of value

Traced it up to ~/.docker/contexts/meta/(some sha256)/meta.json. meta.json was just full of NULs. Deleted it, restarted Docker, and Docker 4.13.0 started working again. meta.json now has JSON.

Can build again.

So, a workaround, but bug wasn’t exactly solved.

For Windows Users

  1. Delete .docker directory. Which exists on PATH C:\Users\your-username\.docker
  2. Restart docker.

My ~/.docker/contexts/meta/(some sha256)/meta.json was also full of nulls. Deleted it, and restarted the docker service only. I was able to docker compose without issue.

solved by: reinstalling docker desktop version 4.12.0

Since I didn’t want to remove the whole ~/.docker folder, I removed only ~/.docker/contexts/meta/(some sha256)/meta.json. Solved the issue.

solved by: reinstalling docker desktop version 4.12.0

Using @nelsonjchen workaround as a guide to my own solution.

On my Windows 10 machine machine, ‘docker context ls’ returns: ‘too many redirects’.

the ~/ .docker/contexts directory is non-existent.

I renamed the ~/.docker directory to something elsse (i.e. ~/.docker-old) and restarted docker.

Everything works.

still not fixed! Docker Desktop 4.16.2 (95914) Windows 11 22H2

My ~/.docker/contexts/meta/(some sha256)/meta.json was also full of nulls. Deleted it, and restarted the docker service only.

Missing the punchline. Did it work?

Solved by adding this to “~/.docker/contexts/meta/(some sha256)/meta.json” {"Name":"desktop-linux","Metadata":{},"Endpoints":{"docker":{"Host":"npipe:////./pipe/dockerDesktopLinuxEngine","SkipTLSVerify":false}}}

Just started using Docker and where what how do I find the .docker/contexts files?

%userprofile%\.docker\contexts

Docker Desktop 4.17 has been released and includes a fix for this 🥳

We do a staged rollout of new releases, so you might not receive a prompt for the in-app update immediately, but you can always click “Check for Updates” in settings or download the latest version manually

Thanks for everyone’s patience, bug reports, and sharing of workarounds in the meantime!

We are aware this is affecting a lot of Compose + Docker Desktop users so are reopening this issue for tracking and visibility.

Internally, we are working on this and will provide an update with the resolution once available. Thanks for your continued patience!

Thanks to everyone who has posted workarounds so far. If one is working for you, please use the GitHub 👍 reaction on the comment to leave a signal for others.

@nelsonjchen your workaround is a lifesaver. Thanks!

Docker Desktop 4.17+ has fixes around this. If you see it after upgrading, manually clean the file (as mentioned ⬆️ @ %USERPROFILE%\.docker\contexts\meta).

Technically, none of them works for me because it is a pain to do it every 5 minutes

docker endpoint for "default" not found

was resolved by deleting ~/.docker/contexts/meta/(some sha256)/meta.json as @nelsonjchen suggested

Docker Desktop 4.16.3 (96739) Each time when I want to build app in Linux env I have to rm -rf ~\.docker\contexts\meta\ because

$ docker context ls
unexpected end of JSON input

dockerConfig

disable Docker Compose V2that worked for me and run docker-compose [“whatever”]

Hi @milon27, Your post’s title attracts attention, but the discussion seems to get longer over time. I suggest you add a TLDR at the top of your first post. You may compose your own or use this:

“”" TL;DR: It turns out this error is caused by one or more broken docker “contexts” after an update, which is tracked in another issue. A quick solution is to remove these broken contexts that reside in %userprofile%\.docker\contexts. be careful as this includes “deleting” things from your computer. “”"

For Windows Users

  1. Delete .docker directory. Which exists on PATH C:\Users\your-username\.docker
  2. Restart docker.

Thanks man, it’s works to me!

Yes, updated comment.

Uninstalling and reinstalling didn’t work for me. Also tried removing & installing Hyper-V and WSL which also didn’t work.

Hi @dallenbaldwin, The issue was solved since v4.17, but it is possible someone broke the fix. Please first check a few things:

  • run docker context ls first, check the discussion for the resulting error.
  • check the last post @ntx-ben gave just before your post.

Check the answers here, specificaly my messages as I tried to summarize possible solutions as much as possible. The discussion is long, but keep your patience as it may possibly solve your issue.

If all fails, we may have a new issue at hand. Then

  • Open a new bug post
  • enter as much detail as required; mainly versions of everything related
  • also give a link back to this post so we can follow it without losing its tracks

Ok, it turns out I was running WSL 2 with a custom kernel to debug Cilium, which somehow became incompatible with Docker?

So I remove the custom kernel from the .wslconfig file, restarted WSL and now I am able to use Docker Desktop v4.17.1

Thanks for the assistance. Case closed.

Hi @maietta , Reinstalling sometimes solves problems, but only sometimes. So it still keeps staying in possible solutions, and worth to give a shot.

Anyways, as you noticed, the problem is those broken meta files that exist even after an update/reinstall process. Developers put lots of effort into it and this should not occur in 4.17 and onwards.

However, it is still possible the update cannot clean up all currently broken files, so the main solution is to find broken context files under %USERPROFILE%\.docker\contexts\meta and remove them or replace them from the backup if any.

Good Luck 😉

@nelsonjchen

C:\WINDOWS\system32>fltmc filters

Filter Name                     Num Instances    Altitude    Frame
------------------------------  -------------  ------------  -----
bindflt                                 1       409800         0
FsDepends                              11       407000         0
DwProt                                 11       323610         0
SpiderG3                               11       323600         0
storqosflt                              2       244000         0
wcifs                                   3       189900         0
CldFlt                                  6       180451         0
FileCrypt                               0       141100         0
luafv                                   1       135000         0
npsvctrig                               1        46000         0
Wof                                     8        40700         0
FileInfo                               11        40500         0

C:\WINDOWS\system32>fltmc volumes
Dos Name                        Volume Name                              FileSystem   Status
------------------------------  ---------------------------------------  ----------  --------
                                \Device\Mup                              Remote
D:                              \Device\HarddiskVolume7                  NTFS
C:                              \Device\HarddiskVolume5                  NTFS
                                \Device\NamedPipe                        NamedPipe
                                \Device\Mailslot                         Mailslot
                                \Device\HarddiskVolume3                  FAT
E:                              \Device\HarddiskVolume2                  NTFS
                                \Device\HarddiskVolume6                  NTFS
C:\ProgramData\Microsoft\Windows\Containers\BaseImages\2fd8febc-ccab-468c-a514-3c07da17377e\BaseLayer  \Device\HarddiskVolume10                 NTFS
K:                              \Device\HarddiskVolume33                 FAT
                                \Device\HarddiskVolumeShadowCopy3        NTFS
                                \Device\HarddiskVolumeShadowCopy4        NTFS
                                \Device\HarddiskVolumeShadowCopy5        NTFS

People will, someday, learn to use that emoji button to tell us it works without telling us it works.

Ran into ERROR: docker endpoint for "default" not found, solved _based on the following https://github.com/docker/compose/issues/9956#issuecomment-1399070673_

Since I didn’t want to remove the whole ~/.docker folder, I removed only ~/.docker/contexts/meta/(some sha256)/meta.json. Solved the issue.

running on Win11:

> docker buildx ls
ERROR: docker endpoint for "default" not found

> rm -r -force ~\.docker\contexts\meta\

> docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS  BUILDKIT PLATFORMS
default * docker
  default default         running 20.10.22 linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6

> docker --version
Docker version 20.10.22, build 3a2c30b

> docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.10.0)
  compose: Docker Compose (Docker Inc., v2.15.1)
  dev: Docker Dev Environments (Docker Inc., v0.0.5)
  extension: Manages Docker extensions (Docker Inc., v0.2.17)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.23.0)

Just started using Docker and where what how do I find the .docker/contexts files?