Search code examples
dockergitlabdockerfilegitlab-ci

Signatures couldn't be verified error while running docker build in Gitlab CI


I am following along with this course by testdriven.io and I can't get my pipeline to finish without error. Basically the goal here is to push the image to the gitlab registry.

The .gitlab-ci.yml file looks like

stages:
  - docker

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: "/certs"

cache:
  key: ${CI_JOB_NAME}
  paths:
    - ${CI_PROJECT_DIR}/services/talk_booking/.venv/

build-python-ci-image:
  image: docker:19.03.0
  services:
    - docker:19.03.0-dind
  stage: docker
  before_script:
    - cd ci_cd/python/
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker build -t registry.gitlab.com/<my_usrnm>/talk-booking:cicd-python3.9-slim .
    - docker push registry.gitlab.com/<my_usrnm>/talk-booking:cicd-python3.9-slim

The ci_ci/python/Dockerfile looks like

FROM python:3.9-slim
RUN mkdir -p /home/gitlab && addgroup gitlab && useradd -d /home/gitlab -g gitlab gitlab && chown gitlab:gitlab /home/gitlab
RUN apt-get update && apt-get install -y curl
USER gitlab
WORKDIR /home/gitlab
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH=/home/gitlab/.local/bin:$PATH
RUN poetry config virtualenvs.in-project true

But I am getting this error at the docker build stage where it looks to execute RUN apt-get update && apt-get install -y curl. Any help would be very much appreciated.

Step 3/8 : RUN apt-get update && apt-get install -y curl
 ---> Running in 8336330cabd7
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Err:1 http://deb.debian.org/debian bookworm InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131 NO_PUBKEY F8D2585B8783D481
Err:2 http://deb.debian.org/debian bookworm-updates InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
Err:3 http://deb.debian.org/debian-security bookworm-security InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54404762BBB6E853 NO_PUBKEY BDE6D2B9216EC7A8
Reading package lists...
W: GPG error: http://deb.debian.org/debian bookworm InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131 NO_PUBKEY F8D2585B8783D481
E: The repository 'http://deb.debian.org/debian bookworm InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian bookworm-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
E: The repository 'http://deb.debian.org/debian bookworm-updates InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian-security bookworm-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54404762BBB6E853 NO_PUBKEY BDE6D2B9216EC7A8
E: The repository 'http://deb.debian.org/debian-security bookworm-security InRelease' is not signed.
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
The command '/bin/sh -c apt-get update && apt-get install -y curl' returned a non-zero code: 100
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 100

Solution

  • I updated the docker version to 24.0.05 and it works now.

    stages:
      - docker
    
    variables:
      DOCKER_DRIVER: overlay2
      DOCKER_TLS_CERTDIR: "/certs"
    
    cache:
      key: ${CI_JOB_NAME}
      paths:
        - ${CI_PROJECT_DIR}/services/talk_booking/.venv/
    
    build-python-ci-image:
      image: docker:24.0.5
      services:
        - docker:24.0.5-dind
      stage: docker
      before_script:
        - cd ci_cd/python/
      script:
        - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
        - docker build -t registry.gitlab.com/<my_usrnm>/talk-booking:cicd-python3.9-slim .
        - docker push registry.gitlab.com/<my_usrnm>/talk-booking:cicd-python3.9-slim