Skip to content

Conversation

@dkaukov
Copy link
Contributor

@dkaukov dkaukov commented Dec 8, 2025

  • Upgrade to Testcontainers 2.0.2
  • Replace deprecated addFileSystemBind with withCopyToContainer
    • For bind-mount-like behaviour we now copy config files into the container using withCopyToContainer instead of addFileSystemBind.
    • This follows Testcontainers’ recommendations and avoids host UID/GID quirks for mounted files.
  • Introduce OwnedTransferable helper
    • Add a small wrapper around Transferable that lets us set file mode and uid/gid on tar entries.
    • Used for files that Postgres is strict about (e.g. key files), where ownership and 0600 permissions are required.

Fix permission/ownership issues on Linux

Previously, temp files created on the host were mounted into the container with the host UID and default 0600 mode. This happened to work on macOS (via Docker Desktop’s VM), but failed on Linux where Postgres runs as a non-root user.

We now:

  • Copy files into the container using OwnedTransferable.
  • Set modes appropriately (e.g. 0600 for key files, 0644 for config/certs).
  • Set uid/gid based on the image variant (Alpine images use postgres as 70:70, other images as 999:999).

This makes the SSL/Vault integration tests pass reliably on both macOS and Linux without requiring root or special host permissions.

**Upgrade to Testcontainers 2.0.2**
**Replace deprecated `addFileSystemBind` with `withCopyToContainer`**

* For bind-mount-like behaviour we now copy config files into the container using `withCopyToContainer` instead of `addFileSystemBind`.
* This follows Testcontainers’ recommendations and avoids host UID/GID quirks for mounted files.

**Introduce `OwnedTransferable` helper**

* Add a small wrapper around `Transferable` that lets us set file mode **and** uid/gid on tar entries.
* Used for files that Postgres is strict about (e.g. key files), where ownership and `0600` permissions are required.

**Fix permission/ownership issues on Linux**

Previously, temp files created on the host were mounted into the container with the host UID and default `0600` mode. This happened to work on macOS (via Docker Desktop’s VM), but failed on Linux where Postgres runs as a non-root user.

We now:

* Copy files into the container using `OwnedTransferable`.
* Set modes appropriately (e.g. `0600` for key files, `0644` for config/certs).
* Set uid/gid based on the image variant (Alpine images use `postgres` as `70:70`, other images as `999:999`).

This makes the SSL/Vault integration tests pass reliably on both macOS and Linux without requiring root or special host permissions.
@dkaukov dkaukov requested a review from mikebell90 December 8, 2025 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant