docker: “build” requires 1 argument. See 'docker build --help'

前端 未结 14 1926
太阳男子
太阳男子 2020-11-28 02:21

Trying to follow the instructions for building a docker image from the docker website.

https://docs.docker.com/examples/running_redis_service/

this is the er

相关标签:
14条回答
  • 2020-11-28 02:38


    You Need a DOT at the end...


    So for example:

    $ docker build -t <your username>/node-web-app .
    

    It's a bit hidden, but if you pay attention to the . at the end...

    0 讨论(0)
  • 2020-11-28 02:39

    In my case this error was happening in a Gitlab CI pipeline when I was passing multiple Gitlab env variables to docker build with --build-arg flags.

    Turns out that one of the variables had a space in it which was causing the error. It was difficult to find since the pipeline logs just showed the $VARIABLE_NAME.

    Make sure to quote the environment variables so that spaces get handled correctly.

    Change from:

    --build-arg VARIABLE_NAME=$VARIABLE_NAME
    

    to:

    --build-arg VARIABLE_NAME="$VARIABLE_NAME"
    
    0 讨论(0)
  • 2020-11-28 02:42

    Just provide dot (.) at the end of command including one space.

    example:

    command: docker build -t "blink:v1" .

    Here you can see "blink:v1" then a space then dot(.)

    Thats it.

    0 讨论(0)
  • 2020-11-28 02:43

    You need to add a dot, which means to use the Dockerfile in the local directory.

    For example:

    docker build -t mytag .

    It means you use the Dockerfile in the local directory, and if you use docker 1.5 you can specify a Dockerfile elsewhere. Extract from the help output from docker build:

    -f, --file="" Name of the Dockerfile(Default is 'Dockerfile' at context root)

    0 讨论(0)
  • 2020-11-28 02:45

    On older versions of Docker it seems you need to use this order:

    docker build -t tag .

    and not

    docker build . -t tag

    0 讨论(0)
  • 2020-11-28 02:48

    Did you copy the build command from somewhere else (webpage or some other file)? Try typing it in from scratch.

    I copied a build command from an AWS tutorial and pasted it into my terminal and was getting this error. It was driving me crazy. After typing it in by hand, it worked! Looking closer and my previous failed commands, I noticed the "dash" character was different, it was a thinner, longer dash character than I got if I typed it myself using the "minus/dash" key.

    Bad:

    sudo docker build –t foo .

    Good:

    sudo docker build -t foo .

    Can you see the difference?.. Cut and paste is hard.

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