I am trying launch a Docker container that has as an entrypoint a python script that accepts a BBOX as an argument. I use a Bash script in order to automate the above.
Where the BBOX should be of this form: lonmin latmin lonmax latmax
Below is the Bash script
run.sh
#! /bin/bash
while getopts ":a" option; do
case "${option}" in
a) bbox="${OPTARG}" ;;
\?)
printf "Illegal option: -%s\n" "$OPTARG" >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))"
# For a bbox inquiry
docker run -it <docker_image_name:tag> --rm --bbox="$bbox"
Where <docker_image_name:tag> is a docker image.
The arguments are passed into the following python script: core.py
. . .
def parse_args():
parser = argparse.ArgumentParser(
prog='core',
usage='%(prog)s [options] path',
description='Download EO Products.',
epilog='Enjoy downloading! :)')
parser.add_argument("--bbox", type=float, nargs=4, help="lonmin latmin lonmax latmax")
return parser.parse_args()
. . .
If I ran the following command it fails
./run.sh -a 3 33 5 40
and raises the following error:
argument --bbox: expected 4 arguments
NOTE!
The following command is successful and it wont raise any errors
python core.py --bbox 3 33 5 40
EDIT
The command ./run.sh -a "3 33 5 40"
passes the arguments as a single string.
Echoing the arguments in the Bash script:
echo -e "BBOX VALUE: $bbox\n"
Output > BBOX VALUE: 3.0 33.0 5.0 40.0
echo -e "BBOX VALUE WITH QUOTES: '$bbox'\n"
Output > BBOX VALUE WITH QUOTES: '3.0 33.0 5.0 40.0'
But it still raises the same error when it is passed to the python script.
Solution:
docker run -it <docker_image_name:tag> --rm --bbox $bbox