Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
Docker --ssh flag - Falló la verificación de clave de host

Estoy tratando de usar Docker para crear una imagen importando un paquete npm alojado en un repositorio privado de github: "mypackage": "git@github.com:myaccount/myrepo.git#v0.0.2"

Esto funciona bien localmente ya que tengo acceso SSH, pero obviamente mi contenedor Docker no lo tiene. Seguí las siguientes guías para implementar esto usando algún reenvío ssh habilitado en 18.09:

https://medium.com/@tonistiigi/build-secrets-and-ssh-forwarding-in-docker-18-09-ae8161d066

https://docs.docker.com/develop/develop-images/build_enhancements/#using-ssh-to-access-private-data-in-builds

Usando el siguiente archivo docker:

 # syntax=docker/dockerfile:experimental FROM alpine # Install ssh client and git RUN apk add --no-cache openssh-client git # Download public key for github.com RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts # Clone private repository RUN --mount=type=ssh npm install

Luego, ejecuta docker build --ssh default . falla con el siguiente error:

 #13 1.309 npm ERR! Host key verification failed. #13 1.309 npm ERR! fatal: Could not read from remote repository. #13 1.309 npm ERR! #13 1.309 npm ERR! Please make sure you have the correct access rights #13 1.309 npm ERR! and the repository exists. #13 1.310 npm ERR! #13 1.310 npm ERR! exited with error code: 128

Estoy siguiendo esta documentación al pie de la letra, pero no tengo suerte. ¿Me estoy perdiendo de algo? Estoy en OSX, pero esto también falla con el mismo error en mi entorno de Travis. ¡Ayudar!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Esto ha funcionado para mí.

Extracción de archivos Docker:

 # syntax=docker/dockerfile:experimental ... RUN mkdir -p -m 0600 /root/.ssh RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts COPY development/config /root/.ssh RUN chmod 0600 /root/.ssh/config RUN --mount=type=ssh git clone **MY_PVT_REPOSITORY**

Este es el contenido del archivo de configuración/desarrollo que puede ver copiado en la tercera línea

 Host bitbucket.org StrictHostKeyChecking no IdentityFile **MY LOCAL PATH**/.ssh/id_rsa

Lo complicado es que debe colocar la ruta del archivo del host en id_rsa, no en la ventana acoplable (como /home/fabio/.ssh/id_rsa y NO /root/.ssh/id_rsa)

Entonces simplemente lanza

 ssh-agent export DOCKER_BUILDKIT=1 docker build --ssh default -f development/Dockerfile .
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!