Задать вопрос
@kosavpa

Как исправить проблему pipeline: unable to resolve docker endpoint: open /certs/client/ca.pem: no such file or directory?

Всем привет, пытаюсь реализовать простой jenkins pipeline, следуя документации и используя Docker.
Вот мои файлы, которые я использую:
jenkins_bind_dockerfile:
FROM docker:dind
EXPOSE 2376/tcp
ENV DOCKER_TLS_CERTDIR=/certs
VOLUME jenkins-docker-certs:/certs/client
VOLUME jenkins-data:/var/jenkins_home


jenkins_dockerfile:
FROM jenkins/jenkins:latest
USER root
RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc https://download.docker.com/linux/debian/gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.asc] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean docker-workflow"
ENV DOCKER_HOST=tcp://docker:2376
ENV DOCKER_CERT_PATH=/certs/client
ENV DOCKER_TLS_VERIFY=1
VOLUME [ "jenkins-data:/var/jenkins_home", "jenkins-docker-certs:/certs/client:ro" ]
EXPOSE 8080/tcp
EXPOSE 5000/tcp


docker-compose.yml:
version: '3.7'

networks:
  jenkins:
    driver: bridge

volumes:
  data:
    name: jenkins-data
  certs:
    name: jenkins-docker-certs

services:
  jenkins:
    container_name: true_jenkins
    build:
      dockerfile: jenkins_dockerfile
    restart: on-failure
    ports:
      - 8080:8080
      - 5000:5000
    depends_on:
      - jenkins_bind
    networks:
      - jenkins

  jenkins_bind:
    container_name: jenkins_bind
    build: 
      dockerfile: jenkins_bind_dockerfile
    restart: on-failure
    privileged: true
    ports:
      - 2376:2376
    networks:
      jenkins:
        aliases:
          - "docker"


В console output jenkins'а вижу следующий вывод:
Started by user Kosolapov Saveliy Pavlovich
Obtained testBuild.jenkins from git https://----O@github.com/kosavpa/fitness-blog-prod-docker-image
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/test
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: git
No credentials specified
Cloning the remote Git repository
Cloning repository https://----@github.com/kosavpa/fitness-blog-prod-docker-image
 > git init /var/jenkins_home/workspace/test # timeout=10
Fetching upstream changes from https://----@github.com/kosavpa/fitness-blog-prod-docker-image
 > git --version # timeout=10
 > git --version # 'git version 2.30.2'
 > git fetch --tags --force --progress -- https://----@github.com/kosavpa/fitness-blog-prod-docker-image +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url https://----@github.com/kosavpa/fitness-blog-prod-docker-image # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 1c3e5a54d604cceae8cca1108675e65a8c36c23f (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 1c3e5a54d604cceae8cca1108675e65a8c36c23f # timeout=10
Commit message: "Update testBuild.jenkins"
First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . node:16.13.1-alpine
Failed to initialize: unable to resolve docker endpoint: open /certs/client/ca.pem: no such file or directory
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker pull node:16.13.1-alpine
Failed to initialize: unable to resolve docker endpoint: open /certs/client/ca.pem: no such file or directory
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
  • Вопрос задан
  • 2255 просмотров
Подписаться 1 Средний 8 комментариев
Решения вопроса 1
в директорию jenkins-docker-certs которая баунд внутрь контейнера как /certs/client положите ca.pem
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
@kosavpa Автор вопроса
Может быть кому пригодится. Поняв что я ошибся при монтировании volume я начал искать инфу и наткнулся на этот сайт. Касательно указания volume в dockerfile там говорится что каждое создание контейнера будет создавать новый том и бесполезно указывать имя тома, соответственно что бы оба сервиса использовали одинаковые папки нужно volume указывать в docker-compose.yml. Вот рабочий вариант всех трех файлов:
jenkins_bind_dockerfile:
FROM docker:dind
EXPOSE 2376/tcp
ENV DOCKER_TLS_CERTDIR=/certs

jenkins_dockerfile:
FROM jenkins/jenkins:latest
USER root
RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc https://download.docker.com/linux/debian/gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.asc] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean docker-workflow"
ENV DOCKER_HOST=tcp://docker:2376
ENV DOCKER_CERT_PATH=/certs/client
ENV DOCKER_TLS_VERIFY=1
EXPOSE 8080/tcp
EXPOSE 5000/tcp

docker-compose.yml:
version: '3.8'

networks:
  jenkins:
    driver: bridge

volumes:
  data:
    name: jenkins-data
  certs:
    name: jenkins-docker-certs

services:
  jenkins:
    container_name: true_jenkins
    build:
      dockerfile: jenkins_dockerfile
    restart: on-failure
    ports:
      - 8080:8080
      - 5000:5000
    volumes:
      - certs:/certs/client:ro
      - data:/var/jenkins_home
    depends_on:
      - jenkins_bind
    networks:
      - jenkins

  jenkins_bind:
    container_name: bind_jenkins
    build: 
      dockerfile: jenkins_bind_dockerfile
    restart: on-failure
    privileged: true
    volumes:
      - certs:/certs/client
      - data:/var/jenkins_home
    ports:
      - 2376:2376
    networks:
      jenkins:
        aliases:
          - docker
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы