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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Docker compose in Bitbucket Pipeline to ECR

I have 3 containers that are built with docker-compose and I need to push these to ECR. This is my current pipeline. How can I get this to push to ECR? I have multiple repositories, one for each container that I need to push too.   

image: python:3.7.2

options:
docker: true

pipelines:
default:
- step:
script:
- pipe: atlassian/aws-ecr-push-image:1.2.0
variables:
AWS_ACCESS_KEY_ID: 'xxxx'
AWS_SECRET_ACCESS_KEY: 'xxxx'
AWS_DEFAULT_REGION: 'xxxx'
IMAGE_NAME: ""
- step:
script:
- pip install docker
- pip install docker-compose
- docker-compose build
- docker push

 

1 answer

0 votes
brbojorque Community Leader Jan 25, 2021

Hi @ragnar.callan ,

You have to specify the ECR endpoint and make sure you are able to authenticate to the ECR.

  • Create an ECR entry
  • Get the endpoint 
  • Authenticate to ECR inside the pipeline
    • ecr login (something similar)
  • Modify the docker push like so below
    • docker push 321321321321.dkr.ecr.us-east-1.amazonaws.com/image:latest

Hi, thanks for the reply. I have created my ECR endpoints. I have 3. One for each containers with different names. In my docker-compose file I labelled the images with the names of these repos. I want to push all 3 images to their respective ECR 

Hi @ragnar.callan ,

Thank you for your question!

You could follow a Build Once Deploy Many approach and implement the next pipeline:

script:
# do other
- ...
- ...

# build the image
- docker-compose build

# use the pipe to push the image_1 to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.2.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image_1
# use the pipe to push the image_2 to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.2.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image_2
# use the pipe to push the image_3 to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.2.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image_3

 Make sure that you provide right IMAGE_NAME for each push:

The name of the image to push to the ECR. The name should be the same as your ECR repository name. Remember that you don't need to add your registry URL in front of the image name, the pipe will fetch this URL from AWS and add it to the image tag for you.


Cheers,
Oleksandr

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

132 views 3 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you