I'm trying to build docker image with this docker file and I need to clone some private repositories from bitbucket.
FROM ubuntu
RUN chsh -s /bin/bash
RUN apt-get update
RUN apt-get install -y git python-pip
ADD private_key_for_deployment /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
RUN echo "StrictHostKeyChecking no" >> /root/.ssh/config
RUN echo >> /root/.ssh/config
RUN echo "Host bitbucket.org" >> /root/.ssh/config
RUN cat /root/.ssh/id_rsa
RUN mkdir -p /usr/src/app/
COPY requirements.txt /usr/src/app/
RUN cat /root/.ssh/config
WORKDIR /usr/src/app/
RUN echo "IdentityFile ~/.ssh/id_rsa" >> /root/.ssh/config
RUN eval "$(ssh-agent)" && \
ssh-add && \
ssh-add -l \
pip install -U -r requirements.txt
COPY . /usr/src/app
WORKDIR /usr/src/app/data_service/
CMD ["python" "data_service.py"]
I've also tried without ssh-add -l
I need to say that this key if working perfectly inside docker container. I've generated the key inside this container started ssh agent added the identity and I'm able to clone repositories there.
EDIT1
This happens when building docker image:
Step 15 : RUN eval "$(ssh-agent)" && ssh-add && pip install -U -r requirements.txt
---> Running in 2b9a79fa7cf3
Agent pid 8
Enter passphrase for /root/.ssh/id_rsa: 2015/07/02 22:26:46 The command [/bin/sh -c eval "$(ssh-agent)" && ssh-add && pip install -U -r requirements.txt] returned a non-zero code: 1
docker build .
? Please add that detail to your Q if it is so.