Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,675
Community Members
 
Community Events
176
Community Groups

Is it possible for Bitbucket pipeline to build a docker image from private ECR base image?

Edited

In our pipeline we would like to build a docker image that uses a base image from a private AWS ECR and then push the build image to our AWS ECR. However when doing that following the standard setup, we got following error:

docker build -t <image-name> .

Sending build context to Docker daemon 3.072kB

Step 1/6 : FROM <AWS-ECR>/<base-image>

Head FROM <AWS-ECR>/v2/<base-image>/manifests/latest: no basic auth credentials

Our pipeline setup is the following
custom:
    build_and_push_to_ecr:
        - step:
         service:
- docker
script:
- export AWS_REGION=<AWS-REGION>
- export AWS_ACCESS_KEY_ID=<AWS-ACCESS-KEY-ID_THEIRS>
- export AWS_SECRET_ACCESS_KEY=<AWS-SECRET-ACCESS-KEY_THEIRS>
- docker build -t <image-name> .
- pipe: atlassian/aws-ecr-push-image:1.4.2
variables:
AWS_ACCESS_KEY_ID: <AWS-ACCESS-KEY-ID_OURS>
AWS_SECRET_ACCESS_KEY: <AWS-SECRET-ACCESS-KEY_OURS>
AWS_DEFAULT_REGION: <AWS-REGION>
DEBUG: 'true'
IMAGE_NAME: <NAME>
TAGS: ${BITBUCKET_BRANCH}

The Dockerfile we want to build looks like

FROM <AWS-ECR>/<base-image>

...

So is it possible for the docker service to build with a private base image or it must be public?

1 answer

1 accepted

0 votes
Answer accepted

Your docker is not logged in with the AWS ECR credentials. You need to add the below line to the script before `docker build`:

 aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ECR 

Thanks!

That did the trick

Could you please share which image you have taken and how do you implemented it? What is the value of $AWR_ECR and where you added this command? a sample bitucket-pipelines.yml could be a great resource to learn

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events