add support for multiple --tag flags in build (#785)

- Closes #732.

## Type of Change
- [ ] Bug fix
- [x] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
Adds support for specifying multiple `-t` / `--tag` flags with the
`build` command. All specified tags will point to the same built image.

Example:
`container build -t myapp:latest -t myapp:v1.0.0 -t myapp:stable .`

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [x] Added/updated docs
This commit is contained in:
Raj
2025-10-21 13:03:46 -07:00
committed by GitHub
parent d610a85703
commit ce40ffd33d
5 changed files with 75 additions and 18 deletions
+6 -4
View File
@@ -243,7 +243,7 @@ public struct Builder: Sendable {
public let noCache: Bool
public let platforms: [Platform]
public let terminal: Terminal?
public let tag: String
public let tags: [String]
public let target: String
public let quiet: Bool
public let exports: [BuildExport]
@@ -260,7 +260,7 @@ public struct Builder: Sendable {
noCache: Bool,
platforms: [Platform],
terminal: Terminal?,
tag: String,
tags: [String],
target: String,
quiet: Bool,
exports: [BuildExport],
@@ -276,7 +276,7 @@ public struct Builder: Sendable {
self.noCache = noCache
self.platforms = platforms
self.terminal = terminal
self.tag = tag
self.tags = tags
self.target = target
self.quiet = quiet
self.exports = exports
@@ -312,9 +312,11 @@ extension CallOptions {
("context", URL(filePath: config.contextDir).path(percentEncoded: false)),
("dockerfile", config.dockerfile.base64EncodedString()),
("progress", config.terminal != nil ? "tty" : "plain"),
("tag", config.tag),
("target", config.target),
]
for tag in config.tags {
headers.append(("tag", tag))
}
for platform in config.platforms {
headers.append(("platforms", platform.description))
}