mirror of
https://github.com/apple/container.git
synced 2026-07-13 04:57:08 +00:00
Add --rosetta option for arm64 images (#846)
`container` automatically enables Rosetta for amd64 containers. This change allows Rosetta to be enabled for arm64 containers by passing the `--rosetta` flag. This allows native containers to benefit from being able to execute the occasional amd64 executable in niche situations, e.g., containers used for cross-compilation. Resolves #391. I considered adding a warning for passing `--rosetta` when it is not necessary, but there wasn't obvious infrastructure for conveying the
This commit is contained in:
@@ -184,6 +184,9 @@ public struct Flags {
|
||||
@Flag(name: [.customLong("rm"), .long], help: "Remove the container after it stops")
|
||||
public var remove = false
|
||||
|
||||
@Flag(name: .long, help: "Enable Rosetta in the container")
|
||||
public var rosetta = false
|
||||
|
||||
@Flag(name: .long, help: "Forward SSH agent socket to container")
|
||||
public var ssh = false
|
||||
|
||||
|
||||
@@ -213,8 +213,10 @@ public struct Utility {
|
||||
)
|
||||
}
|
||||
|
||||
if Platform.current.architecture == "arm64" && requestedPlatform.architecture == "amd64" {
|
||||
config.rosetta = true
|
||||
config.rosetta = management.rosetta || (Platform.current.architecture == "arm64" && requestedPlatform.architecture == "amd64")
|
||||
|
||||
if management.rosetta && Platform.current.architecture != "arm64" {
|
||||
throw ContainerizationError(.unsupported, message: "--rosetta flag requires an arm64 host")
|
||||
}
|
||||
|
||||
config.labels = try Parser.labels(management.labels)
|
||||
|
||||
Reference in New Issue
Block a user