Skip to content

docker-compose up fails in WSL 2 environment #12355

Closed
@blake-mealey

Description

@blake-mealey

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

Activity

blake-mealey

blake-mealey commented on Jun 2, 2020

@blake-mealey
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

akhdanbuchou commented on Jun 3, 2020

@akhdanbuchou

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

Ahmed-Abudayyah commented on Jun 7, 2020

@Ahmed-Abudayyah

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

Ahmed-Abudayyah

Ahmed-Abudayyah commented on Jun 8, 2020

@Ahmed-Abudayyah

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

gaddman commented on Jun 11, 2020

@gaddman

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

SewonYun

SewonYun commented on Jun 12, 2020

@SewonYun

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

liuwenzhuang commented on Jun 12, 2020

@liuwenzhuang

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

ddjsecomea commented on Jun 23, 2020

@ddjsecomea

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

ankurash commented on Jun 24, 2020

@ankurash

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

meymself commented on Jul 11, 2020

@meymself

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

lackovic commented on Aug 3, 2020

@lackovic

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

mattisdada commented on Sep 1, 2020

@mattisdada

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

edwinb24 commented on Sep 4, 2020

@edwinb24

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

jpolania commented on Sep 26, 2020

@jpolania

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

technatelogy commented on Nov 10, 2020

@technatelogy

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'

14 remaining items

zwass

zwass commented on Mar 22, 2021

@zwass

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

AndreasTraut commented on May 3, 2021

@AndreasTraut

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

dukekautington3rd commented on May 19, 2021

@dukekautington3rd

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

ThomasTopuz commented on Sep 5, 2021

@ThomasTopuz

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

saiqulhaq commented on Nov 6, 2021

@saiqulhaq

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

transferred this issue fromdocker/composeon Nov 9, 2021
ealanisg

ealanisg commented on Jan 17, 2022

@ealanisg
  1. rm ~/.docker/config.json

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

docker-robott

docker-robott commented on Apr 17, 2022

@docker-robott
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

Andrew-Staves-Activ commented on May 17, 2022

@Andrew-Staves-Activ

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

docker-robott commented on Jun 16, 2022

@docker-robott
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

locked and limited conversation to collaborators on Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Mordred@mattisdada@zwass@mikermcneil@ankurash

        Issue actions

          `docker-compose up` fails in WSL 2 environment · Issue #12355 · docker/for-win