No meu Dockerfile, eu defino valores ARG e os uso com sucesso em comandos RUN.
No entanto, no meu CMD, o valor ARG não aparece.
Dockerfile:
FROM anapsix/alpine-java:8
MAINTAINER [email protected]
ARG NAME=UNSET
CMD echo NAME is $NAME
Exemplo:
12:29:27 ~/workspaces/k8s/docker > docker build scratch
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM anapsix/alpine-java:8
---> f68f6cb88633
Step 2/4 : MAINTAINER [email protected]
---> Using cache
---> b974feaede6a
Step 3/4 : ARG NAME=UNSET
---> Running in 0d1ebf746c33
---> c58708f2a58c
Removing intermediate container 0d1ebf746c33
Step 4/4 : CMD echo NAME is $NAME
---> Running in 52952d8c9e0d
---> be9dca528d15
Removing intermediate container 52952d8c9e0d
Successfully built be9dca528d15
12:29:33 ~/workspaces/k8s/docker > docker run be9dca528d15
NAME is
Eu esperaria que a linha fosse NAME is UNSET
, ou qualquer valor que eu especificasse (usando docker build --build-arg NAME=whatever
).
Tags docker