Compose: WINDOWS: unable to build simple docker-compose.yml with changed context

Created on 20 Apr 2018  路  16Comments  路  Source: docker/compose

Description of the issue

My docker-compose.yml:

version: '3'

services:
  app:
      image: 'registry.1dal.loc/kek/mekekeke'
      build:
          context: .
          dockerfile: ./docker/app/Dockerfile

Context information (for bug reports)

PS C:\Users\1dal\devel\kek\mekekeke> docker-compose up
Building app
Traceback (most recent call last):
  File "site-packages\docker\utils\utils.py", line 117, in create_archive
OSError: [Errno 22] Invalid argument: 'C:\Users\\1dal\\devel\\kek\\mekekeke\\bin\\console'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 71, in main
  File "compose\cli\main.py", line 127, in perform_command
  File "compose\cli\main.py", line 1039, in up
  File "compose\cli\main.py", line 1035, in up
  File "compose\project.py", line 465, in up
  File "compose\service.py", line 327, in ensure_image_exists
  File "compose\service.py", line 998, in build
  File "site-packages\docker\api\build.py", line 150, in build
  File "site-packages\docker\utils\build.py", line 15, in tar
  File "site-packages\docker\utils\utils.py", line 121, in create_archive
OSError: Can not read file in context: C:\Users\\1dal\\devel\\kek\\mekekeke\\bin\\console
[4756] Failed to execute script docker-compose

Output of "docker-compose version"

docker-compose version 1.20.1, build 5d8c71b2

Output of "docker version"

Docker version 18.03.0-ce, build 0520e24

Output of "docker-compose config"

services:
  app:
    build:
      context: C:\Users\1dal\devel\kek\mekekeke
      dockerfile: ./docker/app/Dockerfile
    image: 'registry.1dal.loc/kek/mekekeke'
version: '3.0'

Steps to reproduce the issue

  1. docker-compose up

Expected result

Builded, container up.

Additional information

Windows 10, Powershell/cmd.exe (same result)

Most helpful comment

I was having the same issue after upgrading to WSL 2 on Windows. Just removed node_modules and vendor folders (JS and PHP dependencies) and recreated them through their respective commands.

It's probably some kind of symlink issue, you can check that by navingating into the node_modules\.bin folder and listing its contents.

All 16 comments

I encountered the same problem as you. I solved this problem temporarily by reinstall the docker-compose version 1.19.0. See #5686.

Hello @mapan1984, thx for info!

I had similar problem in windows, using docker toolbox.
What I did was download the above recomended version of docker-compose.exe (https://github.com/docker/compose/releases/download/1.18.0/docker-compose-Windows-x86_64.exe) and copy directly (overwrite the existent one) in the forlder where docker toolbox is taking it:
C:\Program Files\Docker Toolbox

In my case was problem with dead symlinks, so it is not bug in docker-compose. Closing.

I have a file with 0 byte, and this is also cause a problem.

Restart docker resolve my problem 馃槍

I've just moved from MacOS to Windows 10, and my project has the the same issue building as here, I've tried uninstalling python, reinstalling docker, and replacing the docker-compose executable under C:\Program Files\Docker\Docker\resources\bin
But I'm still getting:

Traceback (most recent call last):
  File "site-packages\docker\utils\build.py", line 96, in create_archive
OSError: [Errno 22] Invalid argument: '\\\\?\\C:\\Users\\username\\sites\\project\\node_modules\\.bin\\_mocha'

During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "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 351, in ensure_image_exists
  File "compose\service.py", line 1106, in build
  File "site-packages\docker\api\build.py", line 160, in build
  File "site-packages\docker\utils\build.py", line 31, in tar
  File "site-packages\docker\utils\build.py", line 100, in create_archive
OSError: Can not read file in context: \\?\C:\Users\username\sites\project\node_modules\.bin\_mocha
[4400] Failed to execute script docker-compose

Dockerfile

FROM node:12.16.1-alpine

RUN apk --no-cache --virtual build-dependencies add \
    python \
    make \
    g++ \
    && npm_config_build_from_source=true yarn

docker compose file:

version: '3.4'
services:
   project:
      build:
        context: .
        dockerfile: 'Dockerfile'
      working_dir: /usr/src/service/
      command: bash -c "yarn dev"
      network_mode: "host"

Nuked my windows installation, fresh without python it seems to work... so python is the culprit

I've just moved from MacOS to Windows 10, and my project has the the same issue building as here, I've tried uninstalling python, reinstalling docker, and replacing the docker-compose executable under C:\Program Files\Docker\Docker\resources\bin
But I'm still getting:

Traceback (most recent call last):
  File "site-packages\docker\utils\build.py", line 96, in create_archive
OSError: [Errno 22] Invalid argument: '\\\\?\\C:\\Users\\username\\sites\\project\\node_modules\\.bin\\_mocha'

During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "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 351, in ensure_image_exists
  File "compose\service.py", line 1106, in build
  File "site-packages\docker\api\build.py", line 160, in build
  File "site-packages\docker\utils\build.py", line 31, in tar
  File "site-packages\docker\utils\build.py", line 100, in create_archive
OSError: Can not read file in context: \\?\C:\Users\username\sites\project\node_modules\.bin\_mocha
[4400] Failed to execute script docker-compose

Dockerfile

FROM node:12.16.1-alpine

RUN apk --no-cache --virtual build-dependencies add \
    python \
    make \
    g++ \
    && npm_config_build_from_source=true yarn

docker compose file:

version: '3.4'
services:
   project:
      build:
        context: .
        dockerfile: 'Dockerfile'
      working_dir: /usr/src/service/
      command: bash -c "yarn dev"
      network_mode: "host"

I have the same issue and can't solve it

docker-compose up and build fails in windows but it works when i execute same command from inside WSL (mine is WSL2).

I had this very issue and it turned out to be the node_modules directory. I created a .dockerignore file and added this https://github.com/garygitton/dockerignore/blob/master/Node.dockerignore

I was having the same issue after upgrading to WSL 2 on Windows. Just removed node_modules and vendor folders (JS and PHP dependencies) and recreated them through their respective commands.

It's probably some kind of symlink issue, you can check that by navingating into the node_modules\.bin folder and listing its contents.

I had this very issue and it turned out to be the node_modules directory. I created a .dockerignore file and added this https://github.com/garygitton/dockerignore/blob/master/Node.dockerignore

I've tried the same thing, worked just fine! Thank you

I was having the same issue after upgrading to WSL 2 on Windows. Just removed node_modules and vendor folders (JS and PHP dependencies) and recreated them through their respective commands.

It's probably some kind of symlink issue, you can check that by navingating into the node_modules\.bin folder and listing its contents.

I have the same problem after upgrading to WSL 2, but isn't there a fix for this beside removing and reinstalling composer and npm packages over and over again?

@lebadapetru Hey there,

The solution I proposed works because symlinks don't work the same in Windows and Linux filesystems. WSL 2 has now incorporated the ext4 filesystem. The way to go is to move your files to the Linux VM to use native Linux symlinks.

The first time you move your files, if they contain Windows symlinks, you will have to "fix" them. Removing node_modules and vendor folders, that may contain those, and rerunning installation commands of node and composer on WSL 2 will recreate them just fine.

Now, don't move those files away from the VM, keep them in there ;)

Hello i'm running docker-desktop on windows 10, since the update it lost my containers Symfony 5.1 project with mysql and phpmyadmin and now i'm getting this error:

PS C:\laragon\www\someproject> docker-compose up -d someproject
Building someproject
Traceback (most recent call last):
  File "site-packages\docker\utils\build.py", line 96, in create_archive
OSError: [Errno 22] Invalid argument: '\\\\?\\C:\\laragon\\www\\someproject\\app\\vendor\\bin\\doctrine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 67, in main
  File "compose\cli\main.py", line 126, in perform_command
  File "compose\cli\main.py", line 1070, in up
  File "compose\cli\main.py", line 1066, in up
  File "compose\project.py", line 615, in up
  File "compose\service.py", line 362, in ensure_image_exists
  File "compose\service.py", line 1125, in build
  File "site-packages\docker\api\build.py", line 160, in build
  File "site-packages\docker\utils\build.py", line 31, in tar
  File "site-packages\docker\utils\build.py", line 100, in create_archive
OSError: Can not read file in context: \\?\C:\laragon\www\someproject\app\vendor\bin\doctrine
[24948] Failed to execute script docker-compose
PS C:\laragon\www\someproject>
Was this page helpful?
0 / 5 - 0 ratings