You can run if condition in RUN for example
#!/bin/bash -x
if test -z $1 ; then
echo "argument empty"
........
else
echo "Arg not empty: $1"
........
fi
Dockerfile:
FROM ...
....
ARG arg
COPY bash.sh /tmp/
RUN chmod u+x /tmp/bash.sh && /tmp/bash.sh $arg
Or you can try this
FROM centos:7
ARG arg
RUN if [ "x$arg" = "x" ] ; then echo Argument not provided ; else echo Argument is $arg ; fi
For Copy you can find this dockerfile helpful
#########
# BUILD #
#########
ARG BASE_IMAGE
FROM maven:3.6.3-jdk-11 AS BUILD
RUN mkdir /opt/trunk
RUN mkdir /opt/tmp
WORKDIR /opt/trunk
RUN --mount=target=/root/.m2,type=cache
RUN --mount=source=.,target=/opt/trunk,type=bind,rw mvn clean package && cp -r /opt/trunk/out/app.ear /opt/tmp
##################
# Dependencies #
##################
FROM $BASE_IMAGE
ARG IMAGE_TYPE
ENV DEPLOYMENT_LOCATION /opt/wildfly/standalone/deployments/app.ear
ENV TMP_LOCATION /opt/tmp/app.ear
ARG BASE_IMAGE
COPY if [ "$BASE_IMAGE" = "external" ] ; then COPY --from=BUILD $TMP_LOCATION/*.properties $DEPLOYMENT_LOCATION \
; COPY --from=BUILD $TMP_LOCATION/*.xml $DEPLOYMENT_LOCATION \
; COPY standalone.conf /opt/wildfly/bin ; fi