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?
How to fix - docker: invalid reference format: repository name must be lowercase? The simplest way to fix the issue by change the image to jhooq-docker-demo so that there is no uppercase character in the image name . docker build -t jhooq-docker-demo .
"docker: invalid reference format" messageThe current directory ( %CD% ) or user profile path ( %USERPROFILE% ) in the command contains a space. To fix the problem, put double quotation marks around any references to a path that contains one or more spaces.
docker run \
-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 --rm -it $1
The image name should be immediately after the -it parameter and so re arrange your run command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With