Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to pass Deployment Variables to deployed Docker images in ECS?

We have a simple pipeline that builds a Docker image with our app, pushes it to DockerHub, and finally deploys it to an ECS cluster.


Each cluster runs to a different environment (e.g. Development, Staging, Production), and we need to pass different environment variables for our application in each of these deployed environments. For example, the Google Analytics Tracker ID is different in Development and in Production.


We are using Deployment Variables in Bitbucket Pipelines to achieve this. For example:


  • Test Deployment
  • Production Deployemtn
    • GOOGLE_ANALYTICS_ID = myProductionId


But we can't figure out this...

How do we take these values (e.g. $GOOGLE_ANALYTICS_ID) in the bitbucket-pipelines.yml file and pass them all the way through to our deployed Docker containers in ECS? What is the best practice approach?

We're new to CI/CD, so trying to figure out what the right approach is.

Do we need to build and deploy separate Docker images for each environment? Or is there a way to pass in these environment variables to ECS as part of deploying the Docker image?


Any help, reference articles, etc, is really appreciated. Thanks

1 answer

0 votes


With Docker, you have two options for adding these environment variables.

  1. Build and deploy the separate Docker images with the different environment variables.
  2. Or create a single Dockerfile without the variable defined (or an empty value). And then pass in the environment specific variable at container startup time. You may need some ECS specific settings here that I'm not familiar with.

How do you normally deploy these images? There might be a field on the relevant deploy API that lets you set runtime environment variables at container startup.



Hi @Philip Hodder

Thanks for your reply. We ended up resolving this a few weeks ago, by passing in the Bitbucket Deployment variables into ECS as part of the TaskDefinition.

So the Docker images don't have any environment variables baked in -- otherwise we'd need to be building different images for each environment. They are specified at the time the container is spun up.

We're using the AWS CLI in our pipeline, but all ECS config is handled via CloudFormation templates.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

762 views 15 10
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