I'm trying to create a shell script to run a docker container and am struggling. My script is like this:
#!/bin/bash
if [ "$1" == "" ]; then
echo "Usage > run.sh IMAGE NAME"
echo
echo "i.e. ./build.sh cd2:0.0.49"
exit
fi
echo $1
docker run -it --rm \
-e NODE_PATH='./src'\
-e NODE_HOST='0.0.0.0'\
-e NODE_ENV='production'\
-e DOCKER=true\
-e PORT='8080'\
-e STAGING=true\
-e SENDGRID_API_KEY='<redacted>'\
-p 8080:8080 $1
When I run: bash run.sh cd2:0.0.50
I get: docker: invalid reference format: repository name must be lowercase.
Even if I do bash run.sh cd:0.0.50
it still fails (echo $1
results in cd2:0.0.50
).
If I run docker run -it --rm -p 8080:8080 cd2:0.0.50
from the command line it works...
Can anyone help?
The image name should be after the -it parameter and so re arrange your run command.