In my projects Docker file I have some environment variables, like this:
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=Password
ENV MSSQL_PID=Developer
ENV MSSQL_TCP_POR
You can set an ARG var_name
and reference ENV to the ARG variables. Then you can replace those variables when docker build the image $ docker build --build-arg var_name=$(VARIABLE_NAME)
For example the add ARG in dockerfile, and have the ENV variable refer to it:
ARG SECRET
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=$SECRET
ENV MSSQL_PID=Developer
ENV MSSQL_TCP_PORT=1433
You can use dock build task and dock push task separately, as buildandpush command cannot accept arguments. And set a variable SECRET
in your pipeline.
The set the Build Arguments SECRET= $(SECRET)
to replace the ARG SECRET
You can also refer to a similar thread.