In my docker file, I have an ARG that I need to further use in CMD. I try doing that via assigning that value to ENV first:
ARG COMPONENT
ENV EOMPONENT_NAME=${COMPONENT}
CMD ["/opt/apps/${COMPONENT_NAME}", "--seed"]
When I build and then run the image, I get an error stat /opt/apps/${COMPONENT_NAME}: no such file or directory: unknown.
- the ENV variable doesn't get resolved.
If I use CMD without square brackets, it all works:
CMD /opt/apps/${COMPONENT_NAME} --seed
I understand the difference between using square braces or not - in the first case it's supposed to just run the command, in the second it wraps it with /bin/sh -c
. But I still don't understand why the env variables don't get resolved when CMD is used with square braces.