Reputation:
This is my Dockerfile, very simple
FROM node:8.12.0-alpine
EXPOSE 3000
CMD [ "node" ]
I run
docker build -t node_alpine .
and
docker run -p 80:3000 node_alpine
but the container doesn't start. when I run
docker ps
I can't see anythings. Why?
Upvotes: 0
Views: 1546
Reputation: 158657
If you just run node
with no arguments, it will read a program from its standard input, and if there is nothing there, it will promptly exit. If you run docker ps -a
you should see the exited container.
I'd recommend setting up an ordinary Javascript development environment on your host. Once you have your application working, write a Dockerfile that COPY
your (built) application into an image, and then use a CMD
to run that.
The Dockerfile you've shown doesn't really do anything. If you do provide Node with a standard input you'll probably get the interactive prompt
docker run --rm -it node:8.12.0-alpine node
but that's a pretty roundabout way to get a language interpreter REPL; just install Node directly on your host and use that for development.
Upvotes: 1