1

I have a Docker container which is bringing up a project which has dependencies in a private repo.

Dockerfile is copying my passwordless SSH keys (permissions are 600 & 644):

COPY docker/config/id_rsa /root/.ssh/
COPY docker/config/id_rsa.pub /root/.ssh/

After copying, Composer dependencies are getting installed:

RUN echo *** >> /etc/hosts \
  && composer config -a -g *URL *USER *PASS \
  && composer install --prefer-dist --no-progress

At the same time I have deleted composer.lock to make sure nothing is left from previous installs.

Repositories part from composer looks like this:

"repositories": [
    {
        "type": "vcs",
        "url": "git@***:***/libs/***.git",
        "options": {
            "ssl": {
                "local_cert": "~/.ssh/id_rsa.pub"
            }
        }
    },
],

And during the creation of container I am getting an error saying:

[RuntimeException]
Failed to execute git clone --mirror 'git@***:***/libs/***.git' '/root/.composer/cache/vcs/.../'
Cloning into bare repository '/root/.composer/cache/vcs/...'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Repository does indeed exist, SSH keys are valid, and strangest of all...if I omit the composer install command and enter the created container, change nothing and do it manually from terminal, it installs everything.

EDIT:

I have also tried manually in the RUN command writing the keys if by any case they weren't available during the container creation, but that didn't help.

I have also tried removing "options" section from Composer

Norgul
  • 4,613
  • 13
  • 61
  • 144

1 Answers1

0

What was missing were these parts in the RUN command:

echo "xxx.xxx.xxx.xxx my_server_name" >> /etc/hosts

ssh-keyscan -t rsa my_server_name >> ~/.ssh/known_hosts 

Once that was done I could omit "options" section completely from Composer

Norgul
  • 4,613
  • 13
  • 61
  • 144