<p>PLease help me, i'm trying to build a docker image but the program is exiting with error code 125. Here is the code for building the image and the error i'm getting.</p>
<pre><code>Run docker build -t $BUILD_IMAGE \ --build-arg GITHUB_SHA=&quot;$GITHUB_SHA&quot; \ --build-arg GITHUB_REF=&quot;$GITHUB_REF&quot; .
invalid argument &quot;gcr.io//devops:767a173e&quot; for &quot;-t, --tag&quot; flag: invalid reference format
See 'docker build --help'.
</code></pre>
<p>Below is my code for building the image.</p>
<pre><code>    - name: Build
      run: |        
        docker build -t $BUILD_IMAGE \
          --build-arg GITHUB_SHA=&quot;$GITHUB_SHA&quot; \
          --build-arg GITHUB_REF=&quot;$GITHUB_REF&quot; .
    # Push the Docker image to Google Container Registry
    - name: Publish
      run: |
        docker push $BUILD_IMAGE
        
</code></pre>

David
<p>Whenever a build is created, for each step/layer docker creates an intermediary image - if you execute the build without setting layers to not be saved, which is the default.</p>
<p>You can debug the last image created before the build crashes. In the displayed messages by the build process, you can see at which step and which command failed. You then access the image and try to execute the command, this way you get a better understanding to what the problem is.</p>
<p>Also, remove the previously cached images:</p>
<pre><code>docker rmi -f $(docker images -aq)
</code></pre>
<p>and after <code>docker build -t &lt;name&gt; .</code> open a shell in the last image:</p>
<pre><code>docker run -ti --rm &lt;IMAGE ID&gt; /bin/bash
</code></pre>
<p>If a step didn't produce an image (e.g. it failed), then commit that step's container to an image and launch a shell container from that temporary image:</p>
<pre><code>docker commit &lt;CONTAINER ID&gt; tempimagename
docker run -ti --rm tempimagename sh
</code></pre>
