skip to Main Content

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.

Run docker build -t $BUILD_IMAGE  --build-arg GITHUB_SHA="$GITHUB_SHA"  --build-arg GITHUB_REF="$GITHUB_REF" .
invalid argument "gcr.io//devops:767a173e" for "-t, --tag" flag: invalid reference format
See 'docker build --help'.

Below is my code for building the image.

    - name: Build
      run: |        
        docker build -t $BUILD_IMAGE 
          --build-arg GITHUB_SHA="$GITHUB_SHA" 
          --build-arg GITHUB_REF="$GITHUB_REF" .
    # Push the Docker image to Google Container Registry
    - name: Publish
      run: |
        docker push $BUILD_IMAGE
        

2

Answers


  1. You should have one slash in your BUILD_IMAGE "gcr.io//devops:767a173e"

    Login or Signup to reply.
  2. 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.

    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.

    Also, remove the previously cached images:

    docker rmi -f $(docker images -aq)
    

    and after docker build -t <name> . open a shell in the last image:

    docker run -ti --rm <IMAGE ID> /bin/bash
    

    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:

    docker commit <CONTAINER ID> tempimagename
    docker run -ti --rm tempimagename sh
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search