title: Docker passing in a variable into an shell script running git clone
body: <p>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.</p>
  
  <p>I looked at <a href="https://stackoverflow.com/questions/32727594/how-to-pass-arguments-to-shell-script-through-docker-run">this SO post</a>, and a few other sites but am stuck on the <code>git clone</code> syntax.</p>
  
  <p>The git clone command returns an error as the variable that is part of it does not contain a value at the <code>docker build</code> stage.</p>
  
  <p>I have this bash script called gitclone.sh  </p>
  
  <pre><code>#!/bin/bash
  git clone $1 /app
  </code></pre>
  
  <p>and in my Dockerfile I have this line:</p>
  
  <p><code>RUN ./gitclone.sh $LOCATION</code> </p>
  
  <p>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.</p>
  
  <p>During the Docker build phase I get the following error:</p>
  
  <blockquote>
    <p>fatal: repository '/app' does not exist</p>
  </blockquote>
  
  <p>The directory is there, but the <code>$1</code> is empty to the command doesn't work.</p>
  
  <p><strong>Question</strong>
  How do I make the Dockerfile work? The desired output I want it:</p>
  
  <p><code>docker run -e LOCATION=https://github.com/something.git -d jwknz/pg02</code></p>
  
  <p><strong>UPDATE</strong>
  Changing my Dockerfile to contain
  <code>CMD ["../gitclone.sh","$LOCATION"]</code> instead of <code>RUN ./gitclone.sh $LOCATION</code> doesn't fix it.</p>
  
  <p>The Dockerfile will build, but the container stops after running the <code>docker run</code> command.</p>