How to fix the problem "Could not resolve hostname" when using Docker

1.6k views Asked by At

I am trying to set up a Satis installation with the official Docker image composer/satis. The private repository I have put uses an SSH key with a passphrase. I use a syntax in the SSH config that allows me to use one key by repository. When I launch docker-compose up with this file :

version: "3.2"
services:
  satis:
    image: composer/satis
    container_name: satis
    hostname: satis
    volumes:
      - /var/www/html/satis:/build
      - /usr/local/bin/composer:/composer/composer
      - ~/.ssh/id_my_repo:/root/.ssh/id_my_repo
      - ~/.ssh/known_hosts:/root/.ssh/known_hosts
      - ~/.ssh/satisConfig.txt:/root/.ssh/config
      #- /~/.ssh/known_hosts:/etc/ssh/ssh_known_hosts

    environment:
      SATIS_CONFIG_FILE: /build/satis.json
      COMPOSER_NO_INTERACTION: 1
      PRIVATE_REPO_DOMAIN_LIST: bitbucket.org gitlab.com github.com
      GIT_SSH_COMMAND: "ssh -v"
    ports:
      - 8181:80

(Obviously, I replace my real repository name). and the satis.json file :

{
  "name": "myuser/my-satis",
  "homepage": "http://my.satis.url",
  "repositories": [
    {
      "type": "vcs",
      "url": "[email protected]:myuser/my-repo.git",
      "name:": "myuser/my-repo",
      "options": {
        "ssh2": {
          "username": "myuser",
          "password": "mypassword",
          "pubkey_file": "/home/myuser/.ssh/id_my-repo.pub",
          "privkey_file": "/home/myuser/.ssh/id_my-repo"
        }
      }
    }
  ]
}

and my SSH config :

Host github.com-my-repo
  Hostname github.com
  IdentityFile=/root/.ssh/id_my_repo

Host *
  UserKnownHostsFile /root/.ssh/known_hosts
  GlobalKnownHostsFile /root/.ssh/known_hosts
  IdentitiesOnly yes
  ServerAliveInterval 30
  ServerAliveCountMax 6

the git command git clone --mirror -- '[email protected]:myuser/mon-repo.git' '/composer/cache/vcs/git-github.com-mon-repo-myuser-mon-repo.git/' fails with the message :

ssh: Could not resolve hostname github.com-my-repo: Name does not resolve

If I launch this command at the outside of the container, it works...so what can be wrong? Docker version 20.10.17, build 100c701. docker-compose version 1.29.2, build 5becea4c

EDIT

I have some slashes before my ~ in front of some of my paths. I fixed that. Now I have :

debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

0

There are 0 answers