Skip to content

Ownership of cache content is transferred to the host user #1870

Description

@byron-hawkins

Minimal .gitlab-ci.yml illustrating the issue

---
job:
  image: 
    name: ubuntu:24.04
    docker:
      user: dockerman
  cache:
    key: foodata
    paths:
      - data
  script:
    - |
      if [ -d "data" ]
      then
        echo "To whom does the cache belong?"
        ls -lhd data
      else
        mkdir data
        echo "foo" >> data/foo.txt
      fi

Expected behavior
Directory data with file data/foo.txt are stored in the cache on the initial run of the job, then restored from the cache with ownership "dockerman:dockerman" on subsequent job runs.

Actual behavior
Directory data is restored with an unknown docker user for whom the UID matches that of the host user. Although cached files were owned by "dockerman:dockerman" during cache push, they mistakenly become owned by "??? (1000):??? (1000)" after cache pull (or in this specific case, "ubuntu:ubuntu", who happens to have UID 1000 in the ubuntu:24.04 image).

Host information
Fedora 42
gitlab-ci-local 4.65.1

Containerd binary
Docker version 29.4.0, build 1.fc42

Additional context

  • host user: griffin (1000) : griffin (1000)
  • image user: dockerman (1001) : dockerman (1001)

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