Skip to content

Add 'privileged' flag for docker-compose publishing - #16075

Merged
Mitch Denny (mitchdenny) merged 1 commit into
microsoft:mainfrom
holystix04:holystix/docker-compose-privileged
Apr 23, 2026
Merged

Mitch Denny (mitchdenny) merged 1 commit into
microsoft:mainfrom
holystix04:holystix/docker-compose-privileged

Conversation

@holystix04

Copy link
Copy Markdown
Contributor

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

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Copilot AI review requested due to automatic review settings April 12, 2026 00:03
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16075

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16075"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 privileged field on the docker-compose Service model so it can be serialized to YAML.
  • Adds a unit test + snapshot to validate privileged: true is emitted when set via PublishAsDockerComposeService.

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>

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
/// </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>

Copilot uses AI. Check for mistakes.
@holystix04

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Glory Global Solutions"

@mitchdenny
Mitch Denny (mitchdenny) merged commit 88eb19f into microsoft:main Apr 23, 2026
283 of 284 checks passed
@github-actions github-actions Bot added this to the 13.3 milestone Apr 23, 2026
@mitchdenny

Copy link
Copy Markdown
Member

Thanks Joshua Clark (@holystix04)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants