azure-cli: --build-arg causes failed builds in Azure Container Registry
I have been trying to use --build-arg to inject Git hashes and build dates like I do in local builds, but whenever I try to use it it inevitably gives me an error in the build agent:
An image does not exist locally with the tag: acmedockerimages.azurecr.io/youtube-dl
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
Since the option is documented, I assume it works. So far I have tried:
local-build:
docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(VCS_REF) \
-t $(LOCAL_IMAGE_NAME) .
cloud-build:
az acr build \
--registry $(REGISTRY_NAME) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(VCS_REF) \
--image $(CONTAINER_NAME) .
…and…
local-build:
docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(VCS_REF) \
-t $(LOCAL_IMAGE_NAME) .
cloud-build:
az acr build \
--registry $(REGISTRY_NAME) \
--build-arg "BUILD_DATE=$(BUILD_DATE)" \
--build-arg "VCS_REF=$(VCS_REF)" \
--image $(CONTAINER_NAME) .
but only this works:
cloud-build:
az acr build \
--registry $(REGISTRY_NAME) \
--image $(CONTAINER_NAME) .
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: c608162e-cf40-9d53-da4a-51f51a0311ea
- Version Independent ID: eccbb543-be68-7de2-d41d-abee55c81452
- Content: az acr
- Content Source: src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_help.py
- Service: container-registry
- GitHub Login: @rloutlaw
- Microsoft Alias: routlaw
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 2
- Comments: 19 (6 by maintainers)
I’m also hitting this and I think the only real solution is for you to fix your
az acr buildimplementation so it packages up the arguments into a file that is then shipped to the server for execution so that any double quoting issues can be handled correctly on your side rather than allowing it to turn into an impossible to debug shell issue on the server side. For example I have this powershell code:And I get this completely useless and totally bogus error message: