Closed dmbarry86 closed 3 years ago
A small update after some further bashing. If I switch to the shell version of CMD, i.e. CMD npm start
then it works. I guess it is maybe looking for an executable which it can't find? However, when I do this the container then immediately shuts down. When used with compose I then need to add stdin_open: true
and tty: true
options to docker-compose file to keep the container alive.
The CMD [ "npm", "start" ]
works fine with Linux Node containers and I don't need to add the extra options to docker-compose. Do you know how they handle it in the Linux containers? Is it possible to make the Windows container syntax equivalent or am I stuck with the differences? I'm currently in the process of migrating one of our Node apps over from Linux to Windows containers, thus my questions. Appreciate any insight you could give.
Thanks for the detailed report.
Oh yes, npm
couldn‘t be found. That‘s because CMD does not look for other extensions than .exe and .bat.
The npm command is a npm.cmd
- put that into your Dockerfile, that should work.
yarn.cmd
did the trick, thank you!
version: "2.1"
services:
app:
build: .
command: "yarn.cmd install && yarn.cmd start"
ports:
- 3000:3000
working_dir: c:/app
volumes:
- ./:c:/app
# restart: unless-stopped
Description
First off, thanks for creating the Node Windows images 👍
I've created an example react-app using
npx create-react-app
. I am then trying to host this inside your "12.18.3-windowsservercore-2019" image. I get an error regarding file not found when trying to execute npm start as entry CMD.Error
Example Dockerfile
If I replace the
CMD [ "npm", "start" ]
with something likeCMD [ cmd.exe ]
and then run the container interactively and executenpm start
from within there it runs just fine. It appears to be an issue when npm start is used as entry CMD. Could it be npm is not on the path somehow? TheRUN npm install
step works just fine though.Machine details
I'm running Windows 10 Pro.
docker version