docker run is the command you will type more than any other. It
takes an image, creates a container from it, and starts the process
inside. The basic shape is:
docker run IMAGE [command]
If the image is not already on the machine, Docker pulls it from the registry first, then runs it.
Most images have a default command, but you can override it by adding
your own after the image name. This runs echo inside a fresh Alpine
Linux container:
docker run alpine echo "hello from inside a container"
Docker pulls the tiny alpine image, starts a container, runs echo,
and the moment echo finishes the container stops. A container lives
exactly as long as its main process. When the process exits, so does
the container.
By default docker run attaches your terminal to the container and
shows its output directly, then hands control back when it exits. Try
a command that lists the container's own filesystem:
docker run alpine ls /
You see the root directory of the container, not your host. That is the isolation from the last topic in action - the process sees its own filesystem.
The first docker run alpine downloads the image. Every run after that
reuses the cached copy and starts almost instantly. You do not pull by
hand for normal use - docker run handles it.
docker run IMAGE - create and start a container from an imagedocker run IMAGE command args - override the default command