moby / moby/buildkit

[feature request/propsal] add option `--keep-ownership` for ADD and COPY commands

Open
#2,875 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

Description

I would love to keep the ownership on ADD and COPY commands, that are copy my files from local and also from images.

Steps to reproduce the issue:

  1. create Dockerfile with ADD and/or COPY from you local storage (owned by 1123:1123)
  2. build it
  3. check the Ownership

Describe the results you received:

files are owned by root:root

Describe the results you expected:

I would expect to have a option ADD --keep-ownership /file /file or COPY --keep-ownership /file /file that keeps the ownership of my files, like 1123:1123 if my user has the UID and GID or the files if I run it as root.

** Additonal references: **
https://github.com/containers/buildah/pull/3767
https://github.com/containers/buildah/pull/4001
https://github.com/openshift/imagebuilder/pull/227

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing BuildKit's Dockerfile ADD and COPY command handling, then compare the linked Buildah and imagebuilder pull requests. Verify how ownership is assigned for local files and image sources. Done means an explicit --keep-ownership option preserves source UID/GID ownership for both commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
dockerfile, go
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.