Card 01/ 06

ConceptDifficulty: Beginner1 min

What `docker run` Does Before Your Program Starts

docker run is one word for three separate things, and knowing which one is slow saves you guessing later.

text
1. Pull the image, if this machine does not already have it
2. Create a container from it, with its own writable layer
3. Start the process the image names, and attach to it

Only the first step touches the network, and only the first time. A second docker run of the same image skips straight to step two, which is why the first start of an image takes thirty seconds and every start after it takes one.

It also means a container exists even when nothing is running in it: step two happened, step three finished. That is what you are looking at when a container appears in docker ps -a and not in docker ps.