I am creating a Dockerfile and as part of this file, I am wanting to give the end user the option to pass in their git repo.
I looked at this SO post, and a few other sites but am stuck on the git clone
syntax.
The git clone command returns an error as the variable that is part of it does not contain a value at the docker build
stage.
I have this bash script called gitclone.sh
#!/bin/bash
git clone $1 /app
and in my Dockerfile I have this line:
RUN ./gitclone.sh $LOCATION
The shell script has the right permissions to run and it works when running it from within the container since I am passing an actual repository to it.
During the Docker build phase I get the following error:
fatal: repository '/app' does not exist
The directory is there, but the $1
is empty to the command doesn't work.
Question How do I make the Dockerfile work? The desired output I want it:
docker run -e LOCATION=https://github.com/something.git -d jwknz/pg02
UPDATE
Changing my Dockerfile to contain
CMD ["../gitclone.sh","$LOCATION"]
instead of RUN ./gitclone.sh $LOCATION
doesn't fix it.
The Dockerfile will build, but the container stops after running the docker run
command.