Docker Community Forums

Share and learn in the Docker community.

Docker push does not rund with no basic auth credentials


(Holzfelix) #1

hi togteher,

I use docker on aws and made a new pipline today. I’ve done everything like bevore but got this error in post build:

no basic auth credentials

my code looks like this:

buildspec.yml

version: 0.1
phases:
  install:
    commands:
      - echo "*** INSTALL:"
      - chmod +x buildspec_install.sh && ./buildspec_install.sh
  pre_build:
    commands:
      - echo "*** PRE-BUILD:"
      - chmod +x buildspec_prebuild.sh && ./buildspec_prebuild.sh
  build:
    commands:
      - echo "*** BUILD:"
      - chmod +x buildspec_build.sh && ./buildspec_build.sh
  post_build:
    commands:
      - echo "*** POST-BUILD:"
      - chmod +x buildspec_postbuild.sh && ./buildspec_postbuild.sh

buildspec_prebuild.sh

#!/bin/bash
printf "%s:%s" "$REPOSITORY_URI" "$IMAGE_TAG" > /tmp/build_tag.out
$(aws ecr get-login)

# delete old docker image
aws ecr batch-delete-image --repository-name $REPOSITORY_NAME --image-ids imageTag=$IMAGE_TAG

install and build works fine.

and then the error occurs in this file:

buildspec_postbuild.sh

#!/bin/bash

# push docker image to aws ec2 container repository

$(aws ecr get-login --region eu-central-1)

docker push "$(cat /tmp/build_tag.out)"

What could be the issue in this case?