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 containerization category.

Last Updated: 2024-03-27

Exec

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

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

Mnemonic:

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