Using a gazebo inside a docker container with private repo dependency

I am trying to run bower installinside a docker container passed as a command indocker-compose.yml

Relevant code in docker-compose.yml:

services:
  assets:
    build: ./src
    command: >
      sh -c '
      bower install --allow-root;
      '

bower.json has the following dependency:

{
  "name": "projectname",
  "version": "version",
  "dependencies": {
    "remote-repo": "ssh://git@remoterepo.url/repo.git#branch"
  }
}

This remote repo is closed. The host machine has the correct SSH credentials to pull from this remote.

I tried passing SSH credentials from my host machine to the docker container 4 or 5 in various ways, but each attempt gives me the same error message:

docker_1   | bower repo#branch          ECMDERR Failed to execute "git 
ls-remote --tags --heads ssh://git@remoterepo.url/repo.git", exit code 
of #128 Host key verification failed. fatal: Could not read from 
remote repository.  Please make sure you have the correct access 
rights and the repository exists.

exec git, , , known_hosts, ssh ( ).

stackoverflow, : qaru.site/questions/37136/...

, ssh, , Docker RUN: https://serverfault.com/questions/132970/can-i-automatically-add-a-new-host-to-known-hosts/316100#316100

, script ( docker-compose up, ) :

cp $HOME/.ssh/id_rsa src/id_rsa

, id_rsa , Docker ( , src )

Dockerfile :

# Make ssh dir
RUN mkdir /root/.ssh/

# Copy over private key, and set permissions
ADD id_rsa /root/.ssh/id_rsa

# Create known_hosts
RUN touch /root/.ssh/known_hosts

# Add remote key
RUN ssh-keygen -R remoterepo.url
RUN ssh-keygen -R remoterepoIP
RUN ssh-keygen -R remoterepo.url,remoterepoIP
RUN ssh-keyscan -H remoterepo.url,remoterepoIP >> /root/.ssh/known_hosts
RUN ssh-keyscan -H remoterepoIP >> /root/.ssh/known_hosts
RUN ssh-keyscan -H remoterepo.url >> /root/.ssh/known_hosts

? , ( ).

+4
1

, , - :

1)
2) known_hosts Dockerfile 3) id_rsa

, . .

, , . .gitignore , .

script, Dockerfile :

# Make ssh dir
RUN mkdir /root/.ssh/

# Copy over private key, and set permissions
COPY id_rsa /root/.ssh/id_rsa
COPY known_hosts /root/.ssh/known_hosts
RUN chmod 600 /root/.ssh/id_rsa

, Dockerfile.

, - : StackOverflow 2014 , : cannot use a secure passphrase, apparently

, -.

0

Source: https://habr.com/ru/post/1661129/


All Articles