Skip to content

Docker executor can lose stdout produced after a slow first script command #1871

Description

@pandasoft-zz

Minimal .gitlab-ci.yml illustrating the issue

---
stages: [test]

rootless-image-job:
  stage: test
  image:
    name: moby/buildkit:rootless
    entrypoint: [""]
  script:
    - buildctl-daemonless.sh --version || true
    - mkdir -p dist
    - echo "rootless image job ok"
    - echo "rootless image job ok" > dist/rootless.txt
  artifacts:
    paths:
      - dist/rootless.txt

Expected behavior
The job should exit with status 0.

The gitlab-ci-local output should include:

rootless image job ok

The artifact dist/rootless.txt should also contain:

rootless image job ok

Actual behavior: the job exits with status 0, and the artifact is created with the expected content, but the stdout line is sometimes missing from the gitlab-ci-local process output.

Host information
Ubuntu 24.04
gitlab-ci-local 4.72.0

Containerd binary
Docker

Additional context
This seems to happen when a Docker job has a slow first script command. In this example, buildctl-daemonless.sh --version || true can take long enough to trigger the issue.

The later commands still run, because the artifact is created. Only stdout relay appears to be lost.

This makes stdout-based checks unreliable for Docker jobs that run a slow setup command before printing output.

From reading the runtime behavior, this may be related to how Docker jobs are attached. Docker start --attach --interactive attaches stdout/stderr and stdin. If the attach session ends too early after stdin closes, later container output may not be relayed even though the container continues and exits successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions