Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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 does source code mounting for Docker containers work?


I'm just getting started implementing CI/CD for embedded ARM code using Bitbucket. I've learned about Docker containers and have successfully found a suitable public image and have successfully done a headless build on my local machine with Docker Desktop, the embedded toolset being Eclipse for ARM (STM32CubeIDE)

In order to do that, I had to create a bind mount for the source code. I'm assuming that when using Bitbucket Pipelines, that something similar is done with the branch(es) being processed. Can someone explain how this works with Bitbucket Pipelines? Without that understanding, I fear I'll fall into pothole trying to get the CI/CD stuff working.

1 answer

0 votes

Hi @jandyman ,

By source code, I assume that you are referring to the source code of the repository where Pipelines is running? (If not, please feel free to correct me/clarify).

For every step of a Pipelines build, a Docker container starts with the image you have specified in your bitbucket-pipelines.yml file. If you haven't specified one, the image atlassian/default-image:latest will be used.

If you have builds that run on branches, then this branch will be cloned in the Docker container with a default depth of 50 (you can change the depth in your yml file). Then the commands of the script in your yml file will be executed in the container, in the directory where the branch of the repo was cloned.

Builds for pull requests run a bit differently, the source branch is cloned in the docker container and then it is merged with the destination branch. Then, the build is executed on the merged code. Please note that no merge is actually happening in the original Bitbucket repo, the code is merged only in the clone in the Docker container where the build runs.

If you run custom builds (triggered manually) or if you manually trigger a pipeline for a certain commit, the repo is cloned and then a git checkout is done for the commit the pipeline is running for, so the repo is in a 'detached HEAD' state.

I'm not sure how you've made your tests locally, but you can also check this guide we have for debugging Pipelines builds locally with Docker, which specifies options for simulating the memory restrictions in Pipelines:

If you have any questions, please feel free to let me know.

Kind regards,

Suggest an answer

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

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,441 views 4 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