docker run -it --rm --name example -v "$PWD":/usr/src/app -w /usr/src/app node:5-slim node index.js
output:
current working directory /usr/src/app
Hello, World!
Unwrapped command line
run - execute the image right away
-i - inherit STDIO and STDOUT from the current shell process
-t - execute the command (the command "node index.js" is at the end)
--rm - remove existing running image
--name example - give the running container user friendly name "example"
-v "$PWD":/usr/src/app - mount current directory inside the docker container as a volume,
set its path as "/usr/src/app"
-w /usr/src/app - set the working directory before running the command
node:5-slim - use the "node:5-slim" as the docker base image for our container (small!)
node index.js - the command to run inside the new container
- More Docker examples at https://gist.github.com/bahmutov/1003fa86980dda147ff6
- Node Docker images at the docker hub
Thank you, as someone learning docker right now the command line breakdown really helped.