Search code examples
azuredockerazure-devopsazure-pipelinesdocker-build

Docker: Is there a limit to the number of build-arg's you can have?


I'm using Azure pipelines and trying to build a docker image but getting stuck on this error:

"docker build" requires exactly 1 argument.

I have over 20 --build-arg ENV_VAL=$(ENV_VAL) (example), and was thinking maybe its throwing that error because of the number of build args.

Anyone got an idea?


Solution

  • 1,It can be caused by the missing of the . at the end of your docker command.

    docker build -f MyDockerfile -t proj:myapp .
    

    The . at the end specify the build context to be the current working directory.

    2,If the build-args you passed has space in it. It can also cause above error. Please check if the $(ENV_VAL) you passed in the build-args has spaces in it. To avoid this. You can wrap the variables in quotes. See below:

     --build-arg ENV_VAL="$(ENV_VAL)"
    

    3,Please also check the format of your docker command, if you copied and pasted your command. There might be some hidden formatting in your command that caused the error.

    If you were using docker task in azure pipeline. you can select the Path to Build context. Select ** to set the build context to the folder where the dockerfile resides.

    enter image description here