Reputation: 866
I am trying to use an example from Docker docs on ARG
FROM ubuntu
ARG TEST
ENV TEST=${TEST:foo}
RUN echo $TEST
Docker docs says:
The variable expansion technique in this example allows you to pass arguments from the command line and persist them in the final image by leveraging the
ENV
instruction.
The build fails with the following error:
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM ubuntu
latest: Pulling from library/ubuntu
16ec32c2132b: Pull complete
Digest: sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
Status: Downloaded newer image for ubuntu:latest
---> 1318b700e415
Step 2/4 : ARG TEST
---> Running in 4130b437fd93
Removing intermediate container 4130b437fd93
---> a31b0f8a81ff
Step 3/4 : ENV TEST=${TEST:foo}
failed to process "${TEST:foo}": unsupported modifier (f) in substitution
Why is this not working? The error sounds like a complete misunderstanding between me and my docker engine.
OS: Ubuntu 20.04.3 LTS Engine: Docker version 20.10.8, build 3967b7d
Upvotes: 1
Views: 1245
Reputation: 12498
You're missing -
, it should be:
FROM ubuntu
ARG TEST
ENV TEST=${TEST:-foo}
Upvotes: 1