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

docker-compose up fails in WSL 2 environment #12355

Closed
blake-mealey opened this issue Jun 2, 2020 · 38 comments
Closed

docker-compose up fails in WSL 2 environment #12355

blake-mealey opened this issue Jun 2, 2020 · 38 comments

Comments

@blake-mealey
Copy link

Description of the issue

Whenever I run docker-compose up in my WSL 2 environment, it fails with the error:

docker.credentials.errors.InitializationError: docker-credential-desktop.exe not installed or not available in PATH
[519] Failed to execute script docker-compose

It's complaining that docker-credential-desktop is not available, however in the same session I can run docker-credential-desktop -h and get the help text output.

I am also able to use docker run to build and run my container without any problems.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 01:25:46 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

services:
  happy:
    build:
      context: /home/blake/repos/happy
      dockerfile: Dockerfile
    container_name: happy
    environment:
      CHOKIDAR_USEPOLLING: "true"
    ports:
    - published: 3001
      target: 3000
    volumes:
    - /home/blake/repos/happy:/app:rw
    - /app/node_modules
version: '3.7'

Steps to reproduce the issue

  1. Create a WSL 2 environment (I'm running Ubuntu 20.04)
  2. Install Docker Desktop
  3. Create a Dockerfile and attempt to run docker-compose up on it

Observed result

The above error message

Expected result

The container is built and run

Stacktrace / full error message

Traceback (most recent call last):
  File "bin/docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 72, in main
  File "compose/cli/main.py", line 128, in perform_command
  File "compose/cli/main.py", line 1077, in up
  File "compose/cli/main.py", line 1073, in up
  File "compose/project.py", line 548, in up
  File "compose/service.py", line 367, in ensure_image_exists
  File "compose/service.py", line 1106, in build
  File "site-packages/docker/api/build.py", line 261, in build
  File "site-packages/docker/api/build.py", line 308, in _set_auth_headers
  File "site-packages/docker/auth.py", line 301, in get_all_credentials
  File "site-packages/docker/auth.py", line 287, in _get_store_instance
  File "site-packages/docker/credentials/store.py", line 25, in __init__
docker.credentials.errors.InitializationError: docker-credential-desktop.exe not installed or not available in PATH
[519] Failed to execute script docker-compose

Additional information

OS version: Windows 10 version 2004 build 19041.264
WSL 2 distro: Ubuntu 20.04

The way I got my setup was:

  • Installed WSL 2 with latest Windows update
  • Installed Docker Desktop and enabled the WSL features
@blake-mealey
Copy link
Author

Update: something I didn't mention above was that I moved my WSL instance to my D drive (because my C drive is pretty full). I thought maybe that could cause problems so I just tried a fresh Ubuntu 20.04 install on the C drive and it seems to be working fine there. This is a temporary workaround which is fine for now but I would like the issue to be fixed still. Thanks :)

@akhdanbuchou
Copy link

i have the same issue in Ubuntu 18.04, tried to reinstall both docker and the Ubuntu but still getting the same error.

@Ahmed-Abudayyah
Copy link

same issue here, Im trying to run docker-compose up for this project.
https://github.com/big-data-europe/docker-hadoop

@Ahmed-Abudayyah
Copy link

looks like they had same issue with mac.
docker/for-mac#3785
I just added _ before credsStore in this file ( ~/.docker/config.json ) {"_credsStore":"desktop.exe"}
I don't know what does that config do but I'm not getting the error anymore.

@gaddman
Copy link

gaddman commented Jun 11, 2020

Removing the file worked for me:
rm ~/.docker/config.json

@SewonYun
Copy link

I did this, and effect me

  1. rm ~/.docker/config.json
  2. docker execute command with sudo prefix : sudo docker-compose -d --build####your option

@liuwenzhuang
Copy link

In my WSL2 Debian, I disable windows path, so I add docker-credential-desktop.exe path to ~/.bashrc:

DockerResourcesBin="/mnt/c/Program Files/Docker/Docker/resources/bin"
export PATH=$PATH:$DockerResourcesBin

and after run source ~/.bashrc, my docker-compose work well.

@ddjsecomea
Copy link

ddjsecomea commented Jun 23, 2020

I have the same issue. I have tried removing the .docker/config.json, commenting out the credsStore attribute, and also adjusting the PATH as suggested above. None of them worked. The only thing that worked was putting the underscore ("_") in front of the credsStore attribute.

@ankurash
Copy link

I have the same issue. I have tried removing the .docker/config.json, commenting out the credsStore attribute, and also adjusting the PATH as suggested above. None of them worked. The only thing that worked was putting the underscore ("_") in front of the credsStore attribute.

This worked for me. In ~/.docker/config.json, change
{"credsStore":"desktop.exe"} to {"_credsStore":"desktop.exe"}

@meymself
Copy link

meymself commented Jul 11, 2020

sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe

does this help? source: #6652 (comment)

@lackovic
Copy link

lackovic commented Aug 3, 2020

I have the same issue.

All the three following solutions mentioned above remove the docker.credentials.errors.InitializationError error message:

  • Renaming credsStore to anything in ~/.docker/config.json or deleting the file altogether

  • adding the path to docker-credential-desktop.exe path to the PATH in ~/.bashrc

  • sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe

All the three solutions creates another issue, when trying to pull any image I get the following error:

ERROR: pull access denied, repository does not exist or may require 'docker login': denied: requested access to the resource is denied 

@mattisdada
Copy link

This was working for me and I decided to do the factory reset to use Buildkit instead, then I started getting this issue. The solution in #6652 (comment) worked perfectly fine for me, but this workaround is pretty un-intuitive.

I hope once this moves into stable, this is addressed (what makes this even more un-intuitive is that none of the images are private, they are all from Docker Hub public)

@edwinb24
Copy link

edwinb24 commented Sep 4, 2020

I tried every potential solution above, and not of them work for me, except for adding "_" to credsStore in this file ~/.docker/config.json: {"_credsStore":"desktop.exe"}

@jpolania
Copy link

Removing the file worked for me:
rm ~/.docker/config.json

It happens when I have my fedora native Linux on the same computer of Windows 10 and pointed out same HOME folder both on Windows and Linux

@technatelogy
Copy link

technatelogy commented Nov 10, 2020

I had a similar issue after switching from edge to stable, but my error was very different. The only reason I found this thread was I noticed it would hang after looking for the auth entry. Changing the credsStore key fixed my issue but my original error message was this:

failed to create file hook: while creating logrus local file hook: unable to get 'APPDATA'

@dzek69
Copy link

dzek69 commented Nov 21, 2020

just a hint for anyone looking at it: this may be wsl2 issue, not docker issue. at work we have a front-end ui library project with storybook project used. when i launch it with configuration that hadn't had anything specific to wsl it crashes inside wsl2 complaining about cmd.exe not being available. No docker is used there at all!

So I think wsl2 may have an issue that causes some popular way of checking OS detecting Windows instead of Linux, so it follows Windows-related logic and it crashes here and there.

Edit: after looking inside ~/.docker/config.json I think this is not the case here and it's Docker's fault :)

@raviwithyou
Copy link

I did this, and effect me

  1. rm ~/.docker/config.json
  2. docker execute command with sudo prefix : sudo docker-compose -d --build####your option

This worked for me!

@Mordred
Copy link

Mordred commented Dec 21, 2020

For me this error was caused by wrong permissions - execute flag was not set on *.exe files in /mnt/c/Program Files/Docker/Docker/resources/bin because I used

[automount]
enabled = true
options = "metadata,umask=22,fmask=111"

No need to remove ~/.docker/config.json after fixing permissions.

@deepyes02
Copy link

I did this, and effect me

  1. rm ~/.docker/config.json
  2. docker execute command with sudo prefix : sudo docker-compose -d --build####your option

this works please try this

@yaahor
Copy link

yaahor commented Jan 5, 2021

For me this error was caused by wrong permissions - execute flag was not set on *.exe files in /mnt/c/Program Files/Docker/Docker/resources/bin because I used

[automount]
enabled = true
options = "metadata,umask=22,fmask=111"

No need to remove ~/.docker/config.json after fixing permissions.

@Mordred, it looks you are right that the reason is permissions, because it works with sudo without deleting, edidting ~/.docker/config.json or creating a symlink.

I don't have wsl.conf and all files /mnt/c/Program Files/Docker/Docker/resources/bin/*.exe have -r-xr-xr-x, but docker.credentials.errors.InitializationError: docker-credential-desktop.exe not installed or not available in PATH occurs. Any ideas?

@Karani42Karaman
Copy link

@jpolania
it solved my problem
thank you

@apazga
Copy link

apazga commented Feb 2, 2021

I needed both things:

First ~/.docker/config.json with:

{"_credsStore":"desktop.exe"}

(removing it seems to work too)

And ensure /etc/wsl.conf has the right permissions (if you don't need it, try removing it to default everything and it should work).

@Karani42Karaman
Copy link

Karani42Karaman commented Feb 4, 2021 via email

@cykonetic
Copy link

cykonetic commented Feb 5, 2021

This issue seems to be with the execution of the cred store:
bin/docker-credential-desktop.exe help
time="2021-02-05T10:33:42-05:00" level=error msg="failed to create file hook: while creating logrus local file hook: unable to get 'APPDATA'"

Setting the Windows APPDATA to %USERPROFILE%\AppData did not work but I am guessing the solution is some where in that direction.
If you are just using the credential store for github, there are solutions for using ssh-agent as an alternative

@diegoclair
Copy link

Hi, I'm with this error too. What is interesting is because this error only happens on Visual Studio Code(vscode) terminal (at least for me).

When I try to run docker-compose up with zsh terminal integrated with vscode, I got this error.
When I try with Windows Terminal, with the same zsh, no problem happens.
After I start the docker-compose from my Windows Terminal for the first time, I can stop and try again in vscode, so the problem not occurs anymore.

Have anyone with this same situation? Or if someone who are with this error, could test if it occurs only in vscode too?

@hazem-elsayed
Copy link

make sure that your current user is part of the docker group by doing the below:
$sudo usermod -aG docker $USER
$exec su -l $USER

@ajithcravi
Copy link

I had the same issue. Resolved on using 'sudo'

@ljr95
Copy link

ljr95 commented Mar 1, 2021

Update: something I didn't mention above was that I moved my WSL instance to my D drive (because my C drive is pretty full). I thought maybe that could cause problems so I just tried a fresh Ubuntu 20.04 install on the C drive and it seems to be working fine there. This is a temporary workaround which is fine for now but I would like the issue to be fixed still. Thanks :)
@blake-mealey

I had the same problem as you after the migration moved my WSL instance to another hard drive.
In the .docker directory I deleted the contexts directory.
It fixed my problem.
Have a good day

@mikermcneil
Copy link

Tested this more than I'd like to admit today and found that either sudo or removing credsStore from ~/.docker/config.json both work.

@zwass
Copy link

zwass commented Mar 22, 2021

FWIW the issue title should perhaps be changed to docker-compose up fails in many environments. We can consistently reproduce this in a macOS environment.

@AndreasTraut
Copy link

AndreasTraut commented May 3, 2021

I had the same issue some days ago and renaming {"credsStore":"desktop.exe"} to {"_credsStore":"desktop.exe"} solved my issue for the moment. Some days later, when I came back to the same docker container and wanted to continue my work, I received a lot of different error messages. One was: "ERROR [internal] load metadata for docker.io/library/python:3.8-slim-buster". So I deleted the "~/.docker/config.json" without knowing what whill happen, but it solved the problem again. So I will delete the "~/.docker/config.json" each time in the future, when I have an error. Seems like the old CTRL+ ALT+ DEL, which solves nearly all problems. :-)

What I did not like in this issue: the error messages are misleading an did not direct me towards the "config.json" file.

@dukekautington3rd
Copy link

I have the same issue although, my conditions are a little bit different:

  • I am running docker CE "Docker version 20.10.6, build 8728dd2" native in WSL2 (Debian Buster) and not Docker Desktop for windows. I followed this guidance: https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9
  • Adding "_credsStore":"desktop.exe" to /etc/docker/daemon.json makes dockerd fail to start. I added because it didn't exist in the first place
  • I can only work around the issue if I docker pull [image] before docker-compose up.

It seems that compose has trouble finding the binary required to auth to a registry.

@ThomasTopuz
Copy link

looks like they had same issue with mac.
docker/for-mac#3785
I just added _ before credsStore in this file ( ~/.docker/config.json ) {"_credsStore":"desktop.exe"}
I don't know what does that config do but I'm not getting the error anymore.

This worked for me, thanks

@saiqulhaq
Copy link

it works if I pull the image first, then docker compose up

@ndeloof ndeloof transferred this issue from docker/compose Nov 9, 2021
@ealanisg
Copy link

  1. rm ~/.docker/config.json

This worked for me, no need of using sudo after, just docker-compise build

@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

@Andrew-Staves-Activ
Copy link

Andrew-Staves-Activ commented May 17, 2022

This is still happening for me - I'm having to run rm ~/.docker/config.json each time I start Docker. (Not sure how to re-open the issue.)
/remove-lifecycle stale

@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 Jun 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests