Node installation with docker not working

Siriwudhi Sawaidee July 22, 2022

I tried to create a Dockerfile for my project. I also installed an external git repository using ssh. When building the project, this error occurred.

 > [builder 6/8] RUN --mount=type=ssh npm ci:
#13 81.97 npm notice
#13 81.97 npm notice New minor version of npm available! 8.11.0 -> 8.15.0
#13 81.97 npm notice Changelog: <>
#13 81.97 npm notice Run `npm install -g npm@8.15.0` to update!
#13 81.97 npm notice
#13 81.97 npm ERR! code 128
#13 81.98 npm ERR! An unknown git error occurred
#13 81.98 npm ERR! command git --no-replace-objects ls-remote ssh://
#13 81.98 npm ERR! Warning: Permanently added '' (RSA) to the list of known hosts.
#13 81.98 npm ERR! Permission denied (publickey).
#13 81.98 npm ERR! fatal: Could not read from remote repository.
#13 81.98 npm ERR!
#13 81.98 npm ERR! Please make sure you have the correct access rights
#13 81.98 npm ERR! and the repository exists.
#13 81.99
#13 81.99 npm ERR! A complete log of this run can be found in:
#13 81.99 npm ERR! /home/node/.npm/_logs/2022-07-22T10_18_37_431Z-debug-0.log
executor failed running [/bin/sh -c npm ci]: exit code: 128

What should I do?

2 answers

1 accepted

0 votes
Answer accepted
Siriwudhi Sawaidee July 26, 2022

The problem occurred because I use another user which isn't the root user in the Dockerfile, and that screwed up the ssh thing. 

To solve this problem, add uid=<user id of the user> to the --mount=type=ssh command

RUN --mount=type=ssh,uid=<user id> npm ci
Roopa Patel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 24, 2023

Hi there I am trying to run Docker container and continually the container showing its restarting and running and then breaks and the restart. Can any one help me here please  

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 26, 2022

Hello @Siriwudhi Sawaidee ,

Welcome to Atlassian Community!

The error message printed in the logs indicates the SSH key you are using to authenticate the git clone command does not have permissions to clone the repository : 

#13 81.98 npm ERR! Permission denied (publickey).

In this case, could you please confirm :

  • Are you running this docker build locally or in Bitbucket pipelines? If in Bitbucket pipelines, I would suggest taking a look at the blog post Cloning another Bitbucket Repository in bitbucket pipelines 
  • Are you copying the private SSH key to your docker image in any of the previous steps of your docker file? If not, you will have to COPY the private SSH  to the path ~/.ssh/id_rsa inside your docker image so it will be used by git
    COPY <path to local ssh key>/my_key ~/.ssh/id_rsa
  • The public ssh key you are using needs to added in a bitbucket account that has access to the repository being cloned or added as an access key in that repository

If after following the suggestions above you are still facing the same error, please share the Dockerfile with us so we can help you investigate further.

Thank you, @Siriwudhi Sawaidee .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events