Skip to content

Add Apple container sentinel file#1779

Open
culpen90 wants to merge 2 commits into
apple:mainfrom
culpen90:changes/apple-container-env
Open

Add Apple container sentinel file#1779
culpen90 wants to merge 2 commits into
apple:mainfrom
culpen90:changes/apple-container-env

Conversation

@culpen90

@culpen90 culpen90 commented Jun 21, 2026

Copy link
Copy Markdown

Type of Change

  • 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

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

@culpen90 culpen90 marked this pull request as ready for review June 21, 2026 13:21
@jglogan

jglogan commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

@culpen90 Thank you for the enhancement!

Have a look at the comment from Anders at the bottom of the issue: #140 (comment).

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

@culpen90 culpen90 changed the title Add Apple container environment identifier Add Apple container sentinel file Jun 29, 2026
@culpen90 culpen90 force-pushed the changes/apple-container-env branch from 82c5f99 to f5ff2fb Compare June 29, 2026 21:38
@culpen90

Copy link
Copy Markdown
Author

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

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.

Detecting Apple’s Container Environment

2 participants