Docker command returns “invalid reference format”

前端 未结 3 1598
无人共我
无人共我 2020-12-09 15:31

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

相关标签:
3条回答
  • 2020-12-09 15:48

    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.

    0 讨论(0)
  • 2020-12-09 16:01

    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

    0 讨论(0)
  • 2020-12-09 16:12

    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

    0 讨论(0)
提交回复
热议问题