Reputation: 4133
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?
Upvotes: 63
Views: 256849
Reputation: 1
You could run the following command:
docker run -d -p 9090:80 -v $(pwd):/usr/share/nginx/html nginx:alpine
instead of $(pwd)
use ${pwd}
if your operating system is Windows.
Upvotes: 0
Reputation: 463
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".
Upvotes: 2
Reputation: 18600
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
Upvotes: 1
Reputation: 411
For me this happened because I left the name blank. Use -t somename
to set a name when building
Upvotes: 3
Reputation: 145
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
Upvotes: 6
Reputation: 263469
Docker is seeing something unexpected before the image name, making it think something in your command other than the nginx:alpine
is your image name. This may be an invalid -
before each of your options, often seen with a copy/paste from the web. It may also be a space in your path. If it's as simple as a space in your path, then quoting it will resolve that:
docker run -d -p 9090:80 -v "$(pwd):/usr/share/nginx/html" nginx:alpine
If the above two do not resolve your issue, first make sure the following works:
docker run nginx:alpine
And then add individual parameters back into your command until you find the one that breaks it. Pay special attention to the order of your args, parameters to run
must be between the run
and your image name. Args after the image name are passed as a command to run. Args before the run
are options to the docker
top level command.
Upvotes: 77
Reputation: 6077
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
Upvotes: 1