Add Apple container sentinel file
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 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 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