Below is a loop I am implementing where a docker image is created and run with the parameters from the loop. I am using jq
to iterate a json
file. Below is the snippet:
jq -c -r '.triggers.endpoint[]' config.json | while read i;
do
echo "Running container for ${i}"
export TEMPLATE_PATH=$1
export BUCKET="something"
export UPPERCASE_ENDPOINT=${i^^}
export NAME="${APPLICATION}_${UPPERCASE_ENDPOINT}"
export PREFIX="something/${i}"
docker run -i -a stdin -a stdout -a stderr --rm \
-v "$PWD":/tmp \
-w /tmp \
-e SLICE \
-e STAGE \
-e PREFIX \
-e AWS_REGION \
-e NAME \
-e BUCKET \
$CONTAINER --verbose $TEMPLATE_PATH
done
The issue I am facing is that the docker run
is ending my bash script, so the loop works perfectly for the first iteration but ends there and does not finish the loop. Running this in detached mode does not work.
Does anyone have any suggestions in how I can debug and figure this issue out?