I have a use case where I would like to not add CMD to the image based on the argument passed when building the image.
docker build -f ./Dockerfile -t ${npm_package_version} . --build-arg arg=test
if the argument is test, then I do not want to add the CMD layer to the image, snippet from the Dockerfile,
RUN if [ "$arg" = "test" ] ; then CMD yarn test ; fi
But this throws the error below,
/bin/sh: CMD: not found
error Command failed with exit code 1.
How can I add CMD yarn test only if the arg is test. Thanks for any help.