I have a really simple Redis bash script that loads some default values into Redis for when my application starts, run in a docker container.
I want to get an ENV var within the bash script passed into my Dockerfile, everytime I run the container and check the logs it says it can't find the set environment var.
My bash script is just
#!/usr/bin/env bash
redis-server --daemonize yes && sleep 1
if [ "$ENVIRONMENT_VAR" = "found" ]; then
echo "found environment var"
fi
A snippet of my Dockerfile where I try and set a default for the value
ENV ENVIRONMENT_VAR notfound
CMD ["sh", "redis.sh"]
And my Docker-Compose I'm passing
environment:
- ENVIRONMENT_VAR=found
Is there something special I need to do to use the ENV value in my bash script?
echo $ENVIRONMENT_VAR, what's its value?