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

pip install a private repo in Bitbucket Pipeline within Dockerfile

I have a private repo that is a dependency as a pip install. I have the proper ssh keys added to the repo I am running the pipeline on, but they are not working within the docker image. How do I get they keys in the docker container so the pip install won't fail?

I have added the following based off of other articles I have read, but once I get to ssh-add ~/.ssh/id_rsa, I get Error loading key "/root/.ssh/id_rsa": invalid format.



- step:
name: Build and Test
- export SSH_PRIVATE_KEY=`cat /opt/atlassian/pipelines/agent/data/id_rsa`
- docker build . --file Dockerfile --tag ${IMAGE_NAME}
- docker save ${IMAGE_NAME} --output "${IMAGE_NAME}.tar"
- docker
- docker
- "*.tar"




RUN mkdir ~/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > ~.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN touch ~/.ssh/known_hosts
RUN ssh-keyscan >> ~/.ssh/known_hosts
RUN eval $(ssh-agent -s)
RUN ssh-add ~/.ssh/id_rsa


1 answer

0 votes

Hi, @Chance Gehrke! Welcome to the community! 

Could you please try to use the following command to build the image?

- docker build --build-arg SSH_PRIVATE_KEY . --file Dockerfile --tag ${IMAGE_NAME}

I hope this helps, but do let me know if you have any questions. 

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,527 views 4 8
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