Docker-compose - TypeError: You must specify a directory to build in path - Win10 WSL 2 docker deamon

The topic already existed, but a year ago and I do not know if there was a solution.

System:

  • Windows 10 - 10.0.19025.1
  • WSL -Unix: Ubuntu 18.04
  • WSL - 2 activated
  • Docker Desktop 2.1.6.0
  • Docker - Deamon on WSL 2

Case:
I cloned a docker-compose repository into my windows wsl 2 environment. I did not manage to succesfully build.

I have 2 ymls in use:

  • docker-compose.yml

    ...
    api:
    command: [ "/opt/startup.sh" ]
    expose:
    - "3000"
    volumes:
    - logs:/var/log/deltaquest
    - versions:/var/versions
    links:
    - db
    - redis
    redis:
    image: redis:3.2
    db:
    image: mongo:4.0
    volumes:
    - mongodb:/data/db
    ...
    
  • docker-compose.override.yml

    ...
    api:
      build:
        context: .
        dockerfile: /api/Dockerfile
    environment:
      - NODE_ENV=development
      - NODE_STAGE=development
    ports:
      - "3000:3000"
      - "9229:9229"
    volumes:
      - ./api/src:/app/src
      - ./api/test:/app/test
      - ./shared/src:/shared/src
      - ./import/dp:/import/dp
     …
    

When I try the following command (out of WLS 2):

docker-compose --verbose build api

the build crashes:

File "site-packages\docker\api\build.py", line 148, in build
TypeError: You must specify a directory to build in path
[14012] Failed to execute script docker-compose

In the stack (unfortunately I cannot upload a file yet), there is mentionned:

compose.cli.verbose_proxy.proxy_callable: docker build <- (path='\\\\?\\\\\\wsl$\\Ubuntu\\home\\donald\\deltaquest', tag='dq_api', rm=True, forcerm=False, pull=False, nocache=False, dockerfile='/api/Dockerfile', cache_from=None, labels=None, buildargs={}, network_mode=None, target=None, shmsize=None, extra_hosts=None, container_limits={'memory': None}, gzip=False, isolation=None, platform=None)

and I what I see there: path=’\\?\\\wsl$\Ubuntu\home\donald\deltaquest …seems weird to me.

I didn’t achieve to change anything in the build process by

  • changing methods of context and or dockerfile
  • same issue I had before upgrading to WSL2 (I wrongly thought that maybe a solution)

Does anyone have any ideas, I’m trying already since a day, no success.
andi

Just an idea: try a directory that is accessible by Docker (somewhere on drive C:). You are now in \\wsl$\Ubuntu..., Windows interprets this as an external share.

1 Like

@tekki , thanks a lot. This fixed the issue:

I still used the WSL 2, but installed on /c/User/[User]/Documents/…/DockerBuild/

-> Therefore I conclude that tools I installed and run on windows I need to point at windows file system.
-> still the question exists, why single docker containers (not compose) do work well, when I build them in WSL filesystem

I was trying to invent an explanation, but when I create a simple image on my own system (Docker Desktop 2.1.5 with “experimental WSL 2 based engine” enabled) using docker-compose in ~ on WSL-Debian, it works. I can even copy a local file into the image. Of course it is not possible to mount a volume from here, but I get no errors.
Things around WSL 2 are changing rapidly at the moment. Maybe if we find an answer it is already outdated.

maybe I should switch to Debian as well. Nevertheless, just an hour ago I achieved with Docker Desktop 2.1.6 to crash the Windows Insider Release till greenscreen. So -

I completely agree.

Docker on WSL in any case needs Ubuntu as standard distribution.

The same happened to me yesterday, that’s why I’m back on 2.1.5. There was a pull request on Github to add a warning to 2.1.6, found it when it was too late.

awesome :rofl::smiley: …I got it now from you.

How did you add Debian then to your WSL, if I may ask?

You can install as many Linux distributions from Microsoft Store as you want. The important is that Ubuntu remains the standard. Check it before you start Docker Desktop, it should look like this:

PS> wsl -l
Ubuntu-18.04 (Standard)
docker-desktop-data
Legacy
Debian
docker-desktop

If Ubuntu is not the standard, set it with

PS> wsl -s Ubuntu-18.04

To start Debian enter

PS> wsl -d debian

docker on Debian will not know that is runs in WSL and has to connect to Docker Desktop, you have to set the current context to tcp://localhost:2375.

1 Like

got it. After I installed Debian via the Microsoft store I’ve seen the way the distribution are linked to the Windows system.

@tekki thank you for all the support. That was very kind.