'Docker command returns "invalid reference format"
I'am using docker and using the following command:
docker run -d -p 9090:80 -v $(pwd):/usr/share/nginx/html nginx:alpine
to point to my /dist folder where my app-files are compiled by angular.
I first go to /dist folder and then run the command from there. This was working fine and I was able to reach the app via port: 9090, but after docker update, I run in error:
docker: invalid reference format. See 'docker run --help'.
I have been searching and checked the following posting docker : invalid reference format, but it seems to be different to my issue.
Here is the info based on the command: docker version:
Client:
Version: 17.09.0-ce
API version: 1.32
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:40:09 2017
OS/Arch: darwin/amd64
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:45:38 2017
OS/Arch: linux/amd64
Experimental: false
Any idea please?
Solution 1:[1]
Your $(pwd) has characters that are not liked (e.g., spaces). Try using quotes around it:
docker run -d -p 9090:80 -v "$(pwd):/usr/share/nginx/html" nginx:alpine
Solution 2:[2]
Seems like you have an invalid name somewhere. Did you try to output pwd ?
Try to change the pwd with a static path.
Take a look at the documentation it might help you as well https://docs.docker.com/v1.10/engine/reference/commandline/run/#mount-volume-v-read-only
Solution 3:[3]
For me this happened because I left the name blank. Use -t somename to set a name when building
Solution 4:[4]
This answer is specific to Google Cloud's Compute Engine (VM Instance).
When specifying the image container to use in the VM settings, including the :latest tag explicitly at the end of the container input was causing the invalid reference format error.
So I had to put this: gcr.io/project/container
Not this: gcr.io/project/container:latest
Solution 5:[5]
If you are running the docker command from within the Shell script then enabling the verbose mode will help in finding the issue.
set -x
set -v
I also came across this issue and while debugging found that image tag was ending with CR character and because of that I was getting "invalid reference format".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ognyan Dimitrov |
| Solution 2 | Mohamed Salem Lamiri |
| Solution 3 | m1212e |
| Solution 4 | contactmatt |
| Solution 5 | Rakesh Chauhan |
