How to remember exec vs run

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the docker category.

Last Updated: 2021-05-16


exec enters a container already running. Therefore it has to take a container ID as an argument:

docker exec -it 93d16d2f2011  bash

What's more, it does not take volume params (since that only matters when first getting that container up-and-runnning)


run spins up a new container. It therefore takes the image name and volume params.

docker run -it -v $PWD:/home/jack fastdotai/fastai-dev bash


Think "run" as in "run away" as in transient