jeudi 12 août 2021

Dockerfile if statement and argument

I have a Dockerfile, I want to copy file if the comparaison is correct for the Dockerfile, but after docker build and docker run, the file is not present on docker, it lack of something ?

ARG A_ARG
RUN if [ "$A_ARG" = "toto" ]; then cp files/opt/toto.sh /opt; chmod +x /opt/toto.sh; fi


docker build --build-arg A_ARG=toto .
docker run id_contenair

I try also

COPY /opt/toto.sh /opt
RUN chmod +x /opt/toto.sh
RUN if [ "$A_ARG" = "titi" ]; then rm /opt/toto.sh; fi

I get the script when my argument is titi, so how could figure out my isssue ?

Aucun commentaire:

Enregistrer un commentaire