Docker command returns "invalid reference format"

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.


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

Tags:

Docker