How to fix 'docker: invalid reference format.'
Problem:
You want to start docker container but you see an error message like this:
docker_invalid_reference.txt
docker: invalid reference format.Solution
Docker is telling you that the syntax of the docker image name (& version) is wrong. Note that this is not the same as docker not being able to find the image in the registry. Docker will not even be able to lookup the image in the registry if you see an invalid reference format error!
Common causes include:
- You used a colon at the end of the image name, e.g.
ubuntu:- omit the colon ; using justubuntuwill refer toubuntu:latest - You used a dash at the end of the image name, e.g.
ubuntu-- omit the dash ; using justubuntuwill refer toubuntu:latest - You used variables like
ubuntu:$VERSIONbut$VERSIONis not set. Ensure you have set$VERSIONto an appropriate (non-empty) value likelatestor18.04! - You used multiple colons like
ubuntu:18.04:2orubuntu:ubuntu:18.04. Use only a single colon in the image name! - You mixed up the order of command line arguments, so another argument is being interpreted as the image name. Check the syntax of your
dockercommand, e.g.docker runand compare some examples with your command.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow