Replies: 2 comments
-
|
i imagine this never got resolved, sadly. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Use @Testcontainers
class FileOwnerTest {
@Container
static GenericContainer<?> container = new GenericContainer<>("alpine:latest")
.withCommand("sleep", "infinity");
@Test
void testFileOwnership() throws Exception {
// Create file with specific ownership
container.copyFileToContainer(
Transferable.of("hello world".getBytes())
.withOwner("myuser:mygroup"), // sets uid:gid
"/tmp/test.txt"
);
// Or copy from local filesystem with ownership
container.copyFileToContainer(
MountableFile.forHostPath("/local/path/config.yml")
.withOwner("1001:1001"), // numeric uid:gid
"/app/config.yml"
);
// For Dockerfile COPY --chown behavior, build the image with:
// COPY --chown=myuser:mygroup file.txt /app/
// and use Testcontainers with that image
}
}The For older Testcontainers versions without container.execInContainer("chown", "-R", "1001:1001", "/app/config.yml"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm trying to copy and mount files into a container with user and group permissions. I explained the problem in details in SO question but didn't get answers there: https://stackoverflow.com/q/67869196/1723695
First, I need to mount some static resource into a container using
withClassPathResourceMapping:And second, copy data to container file with
copyFileToContainer:Both files are used by the application in container on start, but the application is running with
app:appuser. How can I copy and mount resources with correct ownership?Beta Was this translation helpful? Give feedback.
All reactions