StefanScherer / dockerfiles-windows

Various Dockerfiles for Windows Containers
MIT License
1.11k stars 396 forks source link

yarn and npm not in path #374

Closed j-oshb closed 5 years ago

j-oshb commented 5 years ago

If I run:

docker run stefanscherer/node-windows:10.14-build-tools yarn -v

I get the error:

docker : C:\Program Files\Docker\docker.exe: Error response from daemon: container 66a823f72f373a52a75be3f4c6bd19018042351242ac764b130b0f0bda66bda7 encountered an error during CreateProcess:
failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"npm
-v","WorkingDirectory":"C:\\","Environment":{"NPM_CONFIG_LOGLEVEL":"info"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.
    + CategoryInfo          : NotSpecified: (C:\Program File...leSize":[0,0]}.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

It's not a huge issue because you can still use:

docker run stefanscherer/node-windows:10.14-build-tools C:/yarn/bin/yarn.cmd -v

I get the same issue with npm. I guess they're not added to the path.

StefanScherer commented 5 years ago

The PATH is set here https://github.com/StefanScherer/dockerfiles-windows/blob/3c2e7a48471a25867716d1a6bb876be5aaaad92b/node/10/Dockerfile#L70-L71

The problem is that Docker commands or entrypoints search for .exe executable files only. To run npm or yarn which have .cmd extension you have to specify it.

$ docker run stefanscherer/node-windows:10.14 yarn.cmd -v
1.10.1

$ docker run stefanscherer/node-windows:10.14 npm.cmd -v
npm info it worked if it ends with ok
npm info using npm@6.4.1
npm info using node@v10.14.1
npm timing npm Completed in 539ms
npm info ok 
6.4.1

Only the node interpreter can be called without the extension:

$ docker run stefanscherer/node-windows:10.14 node -v
v10.14.1