How to run one-off command in docker

If you want to just run a command on a docker image without permanently creating a container, run

docker_run_example.txt
docker run -it --rm [image] [command]

for example

docker_run_node.sh
docker run -it --rm node:latest npm --version

By using --rm we tell docker to immediately remove the container once the command has finished.


Check out similar posts by category: Allgemein