Trigger starts dependency but can't find docker image built by parent

Parent build has a job that pushes a Docker image to the registry, the next job issues triggers for the dependencies. That much works great.

The childs build script logs into the docker registry (with the ci token) and initiates a build of a Dockerfile. This fails, indicating the FROM image cannot be found (the image pushed by the parent).

If I retry the child build, it works every time. It only fails when initiated from a trigger. If I rerun just the trigger stage from the parent, the child still fails in the same way.

For what it’s worth, both parent and child are using the same shell runner. I am not passing any variables from the parent trigger to the child.

Edit: I am using GitLab CE. I do not seem to have this problem when using GitLab.com
Help is appreciated. Been pulling my hair out.

Can you share your gitlab-ci.yaml file?

Sure. I am testing with a pretty minimal pair of projects, both public, at https://gitlab.com/hdbikeroh/parent2.git and https://gitlab.com/hdbikeroh/child2.git

The parent’s .gitlab-ci.yml is:


image: docker:latest

stages:
  - build
  - triggers

services:
  - docker:dind

before_script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY

build:
  stage: build
  tags:
    - docker
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME"
triggers:
  stage: triggers
  tags:
    - docker
  script:
    - "curl -X POST -F token=$CHILD2_TRIGGER -F ref=$CI_BUILD_REF_NAME https://gitlab.com/api/v3/projects/$CHILD2_PROJECT/trigger/builds"

And the child’s .gitlab-ci.yml file is:


image: docker:latest

stages:
  - build
  - triggers

services:
  - docker:dind

before_script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY

build:
  stage: build
  tags:
    - docker
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME"

triggers:
  stage: triggers
  tags:
    - docker
  script:
    - echo "No triggers configured at this time"

When the child’s build is triggered, it displays:

Step 1 : FROM registry.gitlab.com/hdbikeroh/parent2:master
Pulling repository registry.gitlab.com/hdbikeroh/parent2
Error: image hdbikeroh/parent2:master not found
ERROR: Build failed: exit code 1

I did get this to work (once) on gitlab.com, but it failed just now. It consistently fails on my home gitlab CE installation.

I appreciate any suggestions, as this has me completely stumped. If I restart the child’s CI manually, it works fine every time.

EDIT2: It doesn’t seem to matter if the runner is type docker or shell, or if the child manually does a ‘docker pull’ of the parent image (successfully) before initiating the ‘docker build --pull’. Even if I use a shell runner that has access to my local docker, the child’s ‘docker build --pull’ seems to fail, but only when triggered, not otherwise.

I have exactly the same problem
@hdbikeroh have you solve this ?
Thanks

I encountered this problem too, also on gitlab.com. I’m using webhooks instead of curl inside .gitlab-ci.yml, but I get the exact same behavior as @hdbikeroh.

Any ideas?
Thanks

I’ve also run into this issue. Frustrating to say the least!