6. Docker run command overview

The docker docker run command tells Docker to create and run a new container. A container is a standard unit of software that packages up code and all its dependencies so that the application runs seemlessly across various computing environments. A Docker container image is a lightweight standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Using the example of the birdnet_amphreptiles classifier, here is an overview of the docker run command line by line.

# An example of the docker run command
docker run \
    --shm-size=10.24gb \
    -v $(pwd)/data:/app/input \
    -v $(pwd)/birdnet_processed:/app/birdnet_processed \
    -v $(pwd)/tmp_prediction:/app/tmp_prediction \
    -v $(pwd)/detections:/app/detections \
    -v $(pwd)/species_list:/app/slist \
    naturalstate/birdnet_amph_reptiles:latest \
    --phase_nb 0 \
    --acoustic_test_data /app/input \
    --slist /app/slist
  1. docker run: This is the main command that tells Docker to create and run a new container.

  2. --shm-size=10.24gb: This option allocates 10.24 gigabytes of shared memory for the container. Shared memory allows processes within the container to communicate very quickly. This might be needed by the classifier for processing data.

  3. -v $(pwd)/data:/app/input: This line mounts a volume. The -v flag tells Docker to map a directory on your host machine (the physical computer) to a directory inside the container. Here, $(pwd) refers to the current working directory on your machine, and /data is the directory path inside the container. So, whatever files are in your data folder on your computer will be accessible at /app/input within the container. This likely stores your bird data for classification.

  4. -v $(pwd)/birdnet_processed:/app/birdnet_processed: Similar to the previous line, this mounts another volume. Here, the /birdnet_processed folder on your machine is mapped to /app/birdnet_processed inside the container. This likely stores processed data used by the classifier.

  5. -v $(pwd)/tmp_prediction:/app/tmp_prediction: This mounts another volume, mapping your /tmp_prediction directory to /app/tmp_prediction inside the container. This is a temporary storage location for the classifier’s predictions.

  6. -v $(pwd)/detections:/app/detections: Another volume mount, mapping your /detections folder on the machine to /app/detections inside the container. This is where the classifier stores its final results.

  7. -v $(pwd)/species_list:/app/slist: Similar to above, this mounts your /species_list folder containing a species list to /app/slist inside the container, likely for reference by the classifier.

  8. naturalstate/birdnet_amph_reptiles:latest: This specifies the Docker image to use. Here, it’s using the naturalstate/birdnet_amph_reptiles image from Docker Hub, with the :latest tag indicating the most recent version. This image likely contains the pre-trained machine learning classifier for bird and reptile classification.

  9. --phase_nb 0: This is an argument passed to the program running within the container (the classifier). Here, --phase_nb is likely a custom flag for the classifier, and 0 might specify a particular processing mode.

  10. --acoustic_test_data /app/input: This is another argument for the classifier program. Here, --acoustic_test_data tells the classifier to use the data mounted at /app/input (which maps to your /data folder) as the acoustic test data for classification.

  11. --slist /app/slist: This is the final argument, likely another custom flag for the classifier. Here, --slist tells the program to use the species list mounted at /app/slist (which maps to your /species_list folder) for reference.

In summary, this docker run command creates a container from the naturalstate/birdnet_amph_reptiles image, mounts several folders from your machine to the container, and then runs the machine learning classifier program inside the container with specific arguments to process your data from the mounted folders.