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

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

Closed
0x6B386F opened this issue Apr 20, 2018 · 20 comments
Closed

Comments

@0x6B386F
Copy link

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)

@mapan1984
Copy link

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

@0x6B386F
Copy link
Author

0x6B386F commented May 1, 2018

Hello @mapan1984, thx for info!

@danosilva81
Copy link

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

@0x6B386F
Copy link
Author

0x6B386F commented Jun 6, 2018

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

@0x6B386F 0x6B386F closed this as completed Jun 6, 2018
@zozzz
Copy link

zozzz commented Jul 24, 2018

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

@mamayadi
Copy link

Restart docker resolve my problem 😌

@jimlundblad
Copy link

jimlundblad commented Jun 2, 2020

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"

@jimlundblad
Copy link

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

@NickToTrick
Copy link

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

@ihsanberahim
Copy link

ihsanberahim commented Jul 3, 2020

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

@smplman
Copy link

smplman commented Jul 19, 2020

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

@gdevdeiv
Copy link

gdevdeiv commented Aug 4, 2020

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.

@MatheusLeitao
Copy link

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

@lebadapetru
Copy link

lebadapetru commented Oct 12, 2020

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?

@gdevdeiv
Copy link

@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 ;)

@setlec
Copy link

setlec commented Nov 12, 2020

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>

@quickstar
Copy link

@setlec same issue here :-(

@isaacavelar
Copy link

@setlec
@quickstar

one solution is to go to the 'public' folder and delete the 'storage' file.
this file is a Linux native symlinks

@ruedigerm-playster
Copy link

for me (in my php Laravel project) if just helps to clear only the vendor/bin folder.
rm -f vendor/bin

Like this, composer doesn't have to fully run again.

However, certainly this is not a proper fix of the issue.

@mblaubscher
Copy link

Resolved it by removing node_modules. Had a browser tab open that referenced the files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests