docker : invalid reference format

Like @TarunLalwani and @Oleg mentioned you'll need to move the --rm and -it in-between run and the image name. That won't explain the error message, though. Did you check whether the image name characters don't have any special encoding or upper case? Copy&Paste from your snippet works for me, while docker run --rm foo! bash prints the same error like yours.

Commented Aug 14, 2017 at 21:28 considering posting an answer to this so is easier to find for the next guy Commented Feb 15, 2018 at 9:58

Always double-quote dollar expansions unless you really want to split the string into words. Here, use "$(pwd)" (modern form of "`pwd`" ). Your command becomes docker run -p 8888:8888 -v "$(pwd)"/../src:/src -v "$(pwd)"/../data:/data -w /src supervisely_anpr --rm -it bash .

Commented Jun 21, 2019 at 18:17

29 Answers 29

In powershell you should use $ instead of $(pwd)

39.2k 6 6 gold badges 75 75 silver badges 111 111 bronze badges answered Jul 17, 2018 at 10:59 Levon Petrosyan Levon Petrosyan 9,505 9 9 gold badges 57 57 silver badges 69 69 bronze badges THIS is what caused me to bang my head into the wall (sometimes I hate M$FT) Commented Jan 15, 2019 at 10:25

docker run --rm -ti --name zalenium -p 4444:4444 -p 5555:5555 \ -e SAUCE_USERNAME -e SAUCE_ACCESS_KEY \ -v /tmp/videos:/home/seluser/videos \ -v /var/run/docker.sock:/var/run/docker.sock \ dosel/zalenium start --sauceLabsEnabled true what's wrong with my command? It is also giving same error.

Commented Feb 4, 2019 at 5:45

For anyone having problem like @paul for a perfectly correct command, Please refer to this answer stackoverflow.com/a/65690853/807104

Commented Jan 12, 2021 at 19:37

Why does this work? $(pwd) and $ seem to output the exact same thing when I run the two commands in Powershell.

Commented Aug 13, 2021 at 15:51

The question isn't powershell -tagged, so changing `pwd` to $ alone wouldn't help, due to the \ -based line continuations. It's not clear where the $(pwd) expression you're advising against comes from, given that it isn't mentioned in the question. $(pwd) does work in PowerShell (even though $pwd is preferable), as long as you use it inside ". " , which is generally advisable, e.g., "$(pwd)/../src:/src" (but "$pwd/../src:/src" is better). It's just that $(pwd) , as a subexpression, happens not work as the start of an unquoted compound token /cc @Josh

Commented Oct 27, 2022 at 2:14

I had the same issue when I copy-pasted the command. Instead, when I typed-in the entire command, it worked!

answered Oct 17, 2019 at 3:30 23.3k 7 7 gold badges 105 105 silver badges 88 88 bronze badges

In my case it was the issue of -- and quotes converted to some fancy utf-8 characters that docker did not recognised.

Commented May 19, 2021 at 12:11

In my case it was an "en dash" instead of an ordinary hyphen. This can happen if you copy and paste the command from a web page, or, as in my case, from a PDF file that was intended to be used as a docker cheat sheet.

Commented Jan 29, 2022 at 13:40 Thanks you, for me it was the " \ " caracter of the n8n documentation that I deleted Commented Mar 17, 2022 at 8:41 ok, that solved my issue. Commented Apr 6, 2022 at 20:46 The what. Haha easy to miss this, nice one! Commented Aug 29, 2022 at 20:01

The first argument after the "run" that is not a flag or parameter to a flag is parsed as an image name. When that parsing fails, it tells you the reference format, aka image name (but could be an image id, pinned image, or other syntax) is invalid. In your command:

 docker run -p 8888:8888 -v `pwd`/../src:/src -v `pwd`/../data:/data -w /src supervisely_anpr --rm -it bash 

The image name "supervisely_anpr" is valid, so you need to look earlier in the command. In this case, the error is most likely from pwd outputting a path with a space in it. Everything after the space is no longer a parameter to -v and docker tries to parse it as the image name. The fix is to quote the volume parameters when you cannot guarantee it is free of spaces or other special characters.

When you do that, you'll encounter the next error, "executable not found". Everything after the image name is parsed as the command to run inside the container. In your case, it will try to run the command --rm -it bash which will almost certainly fail since --rm will no exist as a binary inside your image. You need to reorder the parameters to resolve that:

 docker run --rm -it -p 8888:8888 -v "`pwd`/../src:/src" -v "`pwd`/../data:/data" -w /src supervisely_anpr bash