Repository navigation
Add 'privileged' flag for docker-compose publishing - #16075
Mitch Denny (mitchdenny) merged 1 commit into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16075Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16075" |
There was a problem hiding this comment.
Pull request overview
Adds support for emitting Docker Compose’s privileged flag for published services, enabling scenarios (e.g., embedded/device access) where containers must run with elevated privileges.
Changes:
- Introduces a
privilegedfield on the docker-composeServicemodel so it can be serialized to YAML. - Adds a unit test + snapshot to validate
privileged: trueis emitted when set viaPublishAsDockerComposeService.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Docker.Tests/DockerComposePublisherTests.cs | Adds a new test verifying privileged: true is rendered in generated compose output. |
| tests/Aspire.Hosting.Docker.Tests/Snapshots/DockerComposePublisherTests.DockerComposeSetsServicePrivilegedManually.verified.yaml | Adds the verified snapshot containing privileged: true. |
| src/Aspire.Hosting.Docker/Resources/ComposeNodes/Service.cs | Adds Service.Privileged YAML-serialized property for docker-compose output. |
| /// <summary> | ||
| /// Indicates whether the container should run in privileged mode. | ||
| /// When set to true, the container is granted extended Linux capabilities and device access. | ||
| /// </summary> |
There was a problem hiding this comment.
Privileged is part of the exported docker-compose service model, but the XML docs here don’t mention important caveats (e.g., it effectively grants broad host access and is typically only meaningful for Linux containers). Consider adding a <remarks> section that calls out the security implications and platform/runtime limitations so consumers don’t accidentally enable it inappropriately.
| /// </summary> | |
| /// </summary> | |
| /// <remarks> | |
| /// Privileged mode significantly reduces container isolation by granting broad access to host devices | |
| /// and kernel features. Enable this setting only when the workload requires it, because it can | |
| /// effectively provide near-host-level access from inside the container. | |
| /// This option is typically only meaningful for Linux containers, and support or behavior may vary | |
| /// across container runtimes and non-Linux environments. | |
| /// </remarks> |
|
@microsoft-github-policy-service agree company="Glory Global Solutions" |
88eb19f
into
microsoft:main
|
Thanks Joshua Clark (@holystix04) |
Description
Added the docker-compose "privileged" flag for services during publish.
Working on an embedded project that is using Aspire to generate our docker-compose file. We have services that need to run as privileged to communicate with various devices.
Checklist
<remarks />and<code />elements on your triple slash comments?