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

-w workdir flag is broken, tries to interpret argument in Windows #1971

Closed
sdwlig opened this issue Apr 24, 2018 · 4 comments
Closed

-w workdir flag is broken, tries to interpret argument in Windows #1971

sdwlig opened this issue Apr 24, 2018 · 4 comments

Comments

@sdwlig
Copy link

sdwlig commented Apr 24, 2018

Please, check https://docs.docker.com/docker-for-win/troubleshoot/.
Issues without logs and details cannot be debugged, and will be closed.

  • [x ] I have tried with the latest version of my channel (Stable or Edge)
  • [x ] I have submitted Diagnostics
  • [x ] I have included the Diagnostics ID in this Issue
  • Windows Version: Win 10 pro
  • Docker for Windows Version: Docker version 18.04.0-ce, build 3d479c0

Expected behavior

Working directory in container is set to the -w argument.

Actual behavior

Docker reports an error that the path is not absolute, showing a Windows absolute path.
docker run -w /tmp hello-world
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: the working directory 'C:/Users/sdw/AppData/Local/Temp' is invalid, it needs to be an absolute path.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.

Information

F759CEF6-89C7-45A4-97A3-F8A3D3503A68/2018-04-24_05-09-56
Works: docker run hello-world
Doesn't work: docker run -w /tmp hello-world

Steps to reproduce the behavior

  1. Try to use the -w workdir flag which should be relative to the OS in the container, not the host.
  2. ...
@sdwlig
Copy link
Author

sdwlig commented Apr 24, 2018

A similar error affects the command passed to docker:
Works: winpty docker exec -it abjs /../bin/bash
Broken: winpty docker exec -it abjs /bin/bash
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: "C:/Program Files/Git/usr/bin/bash.exe": stat C:/Program Files/Git/usr/bi
n/bash.exe: no such file or directory": unknown

@mat007
Copy link
Member

mat007 commented Apr 24, 2018

This is coming from Git for Windows, see their release notes (under Known issues):

If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe". When that is not desired -- e.g. "--upload-pack=/opt/git/bin/git-upload-pack" or "-L/regex/" -- you need to set the environment variable MSYS_NO_PATHCONV temporarily, like so:

MSYS_NO_PATHCONV=1 git blame -L/pathconv/ msys2_path_conv.cc

Alternatively, you can double the first slash to avoid POSIX-to-Windows path conversion, e.g. "//usr/bin/bash.exe".

In your case try docker run -w //tmp hello-world.

@mat007 mat007 closed this as completed Apr 24, 2018
@sdwlig
Copy link
Author

sdwlig commented Apr 24, 2018

Thanks! I didn't dig deep enough to analyze MSYS...

I had tried // in some other cases. It appears that in that case I may have used a non-existent path which results in a similar error for a different reason.

The environment variable doesn't solve it completely, but with the // it seems to right now:
Works:
winpty docker exec -it nginx //bin/sh
Doesn't:
MSYS_NO_PATHCONV=1 winpty docker exec -it nginx /bin/sh
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: "C:/Program Files/Git/usr/bin/sh.exe": stat C:/Program Files/Git/usr/bin/sh.exe: no such file or directory": unknown

visr added a commit to visr/BinaryProvider.jl that referenced this issue May 10, 2019
Without this on a Windows system with Git for Windows installed, I get:
```
docker: Error response from daemon: the working directory '\workspace\' is invalid, it needs to be an absolute path.
```

Apparently this is a known issue with Git for Windows: docker/for-win#1971 (comment)

It seems harmless to prepend a slash on any platform, to work around this.
staticfloat pushed a commit to JuliaPackaging/BinaryBuilder.jl that referenced this issue Oct 28, 2019
Without this on a Windows system with Git for Windows installed, I get:
```
docker: Error response from daemon: the working directory '\workspace\' is invalid, it needs to be an absolute path.
```

Apparently this is a known issue with Git for Windows: docker/for-win#1971 (comment)

It seems harmless to prepend a slash on any platform, to work around this.
giordano pushed a commit to JuliaPackaging/BinaryBuilderBase.jl that referenced this issue Jun 9, 2020
Without this on a Windows system with Git for Windows installed, I get:
```
docker: Error response from daemon: the working directory '\workspace\' is invalid, it needs to be an absolute path.
```

Apparently this is a known issue with Git for Windows: docker/for-win#1971 (comment)

It seems harmless to prepend a slash on any platform, to work around this.
@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 28, 2020
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

3 participants