SSH forwarding in a docker build context

Inside a docker I am building another docker and trying to share the ssh key. And when building the docker do not have this problem sometimes SSH Permissions not working on CircleCI v2.0

Dokerfile

FROM node:8.9

WORKDIR /tmp

COPY .ssh .ssh

WORKDIR /

RUN cp -r /tmp/.ssh ~/.ssh
RUN eval "$(ssh-agent -s)"

RUN rm -rf /tmp

RUN mkdir /app
ADD . /app

WORKDIR /app

RUN yarn install
RUN yarn build

CMD ["yarn", "start"]

When I try it, it gives me this problem.

COPY failed: stat /var/lib/docker/tmp/docker-builder225467840/.ssh: no such file or directory

What command are you using for your docker build?

Assuming it’s the COPY .ssh .ssh line that is causing the problem, do you have a file/folder called .ssh in your working directory in the build container?

What image are you using for your build container? I take it you are using the Docker executor under 2.0?

“What command are you using for your docker build ?”

  • docker build --cache-from=app -t ${KUBERNETES_SERVICE_NAME} -f Dockerfile ${ARGS} .

“Assuming it’s the COPY .ssh .ssh line that is causing the problem, do you have a file/folder called .ssh in your working directory in the build container?”
yes
08

“What image are you using for your build container?”

“I take it you are using the Docker executor under 2.0?”

  • yes

I wonder if you are in a different directory when your build command runs. Do an ls -l in your run step prior to the build.

Edit: you do not have a Dockerfile in there, but your -f command indicates you are relying on the current working directory.

Aside: when quoting someone else here, please use a quote block, so that they are notified. Select their text and click ‘quote’:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.