GoogleContainerTools / GoogleContainerTools/jib

Jib Core: Cannot set file entry layer ownership using <user name>:<group name> in Linux base image

Open
#2,665 2 comments 0 reactions 0 assignees View on GitHub
area/jib-core priority:p4 type: feature request
Dominant language
Java
Stars
14.5k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

- 0.15.0
- Using linux based image

When using Jib core to add file entries layer, I am trying to specify ownership using String username:groupname. However this doesn't seem to work and always ends up setting layer ownership to root user.

**Steps to reproduce**:
Try something similar to the following Java code where it is attempting to set ownership of layer using user/group name. If you inspect the result image, you will see that the file 1 belongs to root user.
Jib.from("linux based image with created user user1 and group group1")
.addFileEntriesLayer(FileEntriesLayer.builder()
.addEntry(Paths.get("1"), AbsoluteUnixPath.get("/1"), FilePermissions.fromOctalString("644"),
FileEntriesLayer.DEFAULT_MODIFICATION_TIME, "user1:group1")
.build())
.containerize(Containerizer.to(DockerDaemonImage.named("jib_test:latest"))
.addEventHandler(LogEvent.class,
logEvent -> System.out.println(logEvent.getLevel() + ": " + logEvent.getMessage()))
.setApplicationLayersCache(Paths.get("cache")).setBaseImageLayersCache(Paths.get("cache")));

**Why I think this may be happening**
Looking at the code in jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java, I see that the tar entry user id and group id is being initialized to 0. When user name and group name are provided, the entry's user and group id still have the value 0. In Linux systems, 0 is the uid and gid of root. I haven't had time to look into apache's tar entry code, but I feel that uid would take precedence over uname.

Please let me know if you need any more information about this or if I am using this incorrectly

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.