docker run -v `pwd`:/app -p 8900:8900 node:12 sh -c "npm install && npm start"
In general, even though it might sound rude, but docs.docker.com/engine/reference/c... is pretty exhaustive and should be read first.
Nevertheless your approach to go for a docker compose solution helps to make it better portable also for other users/developer of your code.
Thank you for covering for me! I only just saw the reply comment. In addition to that you will need -w /app to change the working directory.
-w /app
For completeness for anyone else reading,
-v
pwd
-p
-p localhost:8900:8900
node:12
sh -c "..."
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In general, even though it might sound rude, but docs.docker.com/engine/reference/c... is pretty exhaustive and should be read first.
Nevertheless your approach to go for a docker compose solution helps to make it better portable also for other users/developer of your code.
Thank you for covering for me! I only just saw the reply comment. In addition to that you will need
-w /app
to change the working directory.For completeness for anyone else reading,
-v
mounts the volume /app to your current path (pwd
gets your current path)-p
maps the ports. I would also change this-p localhost:8900:8900
just so it's only accessible from localhostnode:12
specifies the container image. Docker hub hosts the iamgesh -c "..."
is the command to run on entry