docker run creates and starts a container from an image, optionally passing arguments to the image's task. For example, an image can run a weather task for Amsterdam or display a CLI script's help output. section 11.2.4 section 11.4.2
Use docker run to:
- Pass task arguments after the image name, such as a city name or a script command. section 11.2.4 section 11.4.2
- Mount a host directory with --volume so the container can read or persist files outside its isolated filesystem. section 11.2.4
- Remove the container automatically after completion with --rm, avoiding leftover stopped containers. section 11.2.4
- Inspect, stop, or remove containers with docker ps, docker stop, and docker rm when cleanup is needed. section 11.2.4
Persisting weather output
Mount the local data directory at /data and write the container's output there: docker run --rm --volume `pwd`/data:/data manning-airflow/wttr-example Amsterdam --output_path /data/amsterdam.out. The resulting file appears as data/amsterdam.out on the host. section 11.2.4
Testing a task image
After building manning-airflow/movielens-fetch, run docker run --rm manning-airflow/movielens-fetch fetch-ratings --help to verify that the packaged CLI exposes its required options. section 11.4.2
Listing 11.8 Persisting output from the wttr container
$ docker run --rm --volume `pwd`/data:/data \ manning-airflow/wttr-example Amsterdam \ --output_path /data/amsterdam.out #1
Use the complete volume-mounted command as a compact reference for passing task arguments, persisting output, and removing the finished container. section 11.2.4



