From 3a938749e9271e2dda8fd623465bade641e41b9b Mon Sep 17 00:00:00 2001 From: Shourai <10200748+Shourai@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:18:01 +0200 Subject: [PATCH] Added til about running a docker container interactively --- docker/run-docker-container-interactively.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docker/run-docker-container-interactively.md diff --git a/docker/run-docker-container-interactively.md b/docker/run-docker-container-interactively.md new file mode 100644 index 0000000..1b5d91f --- /dev/null +++ b/docker/run-docker-container-interactively.md @@ -0,0 +1,18 @@ +# Run docker container interactively with bash + +``` +docker run -it --rm -v $(pwd):/tmp -w /tmp CONTAINER_NAME /bin/bash +``` + +``` +-v : mount a certain directory +-w : set working dir inside the container +``` + +If you want to run a script when the container runs without running an interactive tty, you can use + +``` +docker run --rm -v ~/scripts:/tmp -w /tmp node /bin/bash -c "node index.js" +``` + +This command runs the `node` container and executes `index.js` using bash to execute `node index.js`