container icon indicating copy to clipboard operation
container copied to clipboard

Add Apple container sentinel file

Open culpen90 opened this issue 5 months ago • 2 comments

Type of Change

  • [x] Bug fix
  • [ ] New feature
  • [ ] Breaking change
  • [ ] Documentation update

Motivation and Context

Fixes #140.

This adds a read-only /run/.containerenv sentinel file for Linux containers so applications have a reliable Apple container detection signal without changing the process environment.

Testing

  • [x] Tested locally
  • [ ] Added/updated tests
  • [ ] Added/updated docs
swift build --target ContainerRuntimeLinuxServer

culpen90 avatar Jun 21 '26 13:06 culpen90

@culpen90 Thank you for the enhancement!

Have a look at the comment from Anders at the bottom of the issue: https://github.com/apple/container/issues/140#issuecomment-3015180849.

Can you implement the container sentinel using an env file instead? Ideally this change could be limited to just the RuntimeService.

jglogan avatar Jun 27 '26 17:06 jglogan

@jglogan Thanks, updated this to use an env file sentinel instead.

The runtime now writes .containerenv with container=apple under the RuntimeService root and mounts it read-only at /run/.containerenv. The process environment is no longer modified, and the PR diff is limited to RuntimeService.swift.

Validated locally with:

swift build --target ContainerRuntimeLinuxServer

culpen90 avatar Jun 30 '26 00:06 culpen90