docker run --rm -it -v "$PWD":/app -w /app node:22 bash
--rmdeletes the container when you exit-itgives you an interactive shell-v "$PWD":/appmounts the current folder at/app-w /appstarts you there
Inside, npm install and npm test work on your actual files. Everything you install into the image is gone when you leave; everything you write to /app stays.
The same trick for a one-off command:
docker run --rm -v "$PWD":/app -w /app python:3.12 python script.py
On Linux, files created inside are owned by root. Add -u "$(id -u):$(id -g)" to avoid that.