Docker, one or more build-args where not consumed
Solution 1:
ARG
ARG <name>[=<default value>]
The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the --build-arg = flag. If a user specifies a build argument that was not defined in the Dockerfile, the build outputs a warning.
[Warning] One or more build-args [foo] were not consumed.
https://docs.docker.com/engine/reference/builder/#arg
Using ARG variables
You can use an ARG or an ENV instruction to specify variables that are available to the RUN instruction. Environment variables defined using the ENV instruction always override an ARG instruction of the same name. Consider this Dockerfile with an ENV and ARG instruction.
Unlike an ARG instruction, ENV values are always persisted in the built image. Consider a docker build without the --build-arg flag:
ARG is only available during the build of a Docker image (RUN etc), not after the image is created and containers are started from it (ENTRYPOINT, CMD). You can use ARG values to set ENV values to work around that.
So you need to do something like this
# Assign any default value to avoid any error. do not worry your build flag will override this.
ARG ADMIN_PORT=some_default_value
ENV ADMIN_PORT=${ADMIN_PORT}
https://vsupalov.com/docker-arg-env-variable-guide/
Update:
In simple Word, If you pass ARGs like --build-arg SOME_ARG=some_value
to Docker build and did not declare the ARGS in Dockerfile this warning will be printed.
my Dockerfile to consume ARG
FROM alpine
ARG SOME_ARG="Default_Value"
RUN echo "ARGS is ${SOME_ARG}"
Build command
docker build --no-cache --build-arg SOME_ARG=some_value -t alpine .
So it will not print any Warning as ARGS is declared in my Dockerfile.
Now if try to remove ARGS from Dockerfile and build the image
FROM alpine
RUN echo "without ARGS dockerfile"
Build command
docker build --no-cache --build-arg SOME_ARG=some_value -t alpine .
So now we will get a [Warning] One or more build-args [SOME_ARG] were not consumed because we did not consume or declared SOME_ARG in our Dockerfile.