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
+4 -1
View File
@@ -102,7 +102,7 @@ container build [OPTIONS] [CONTEXT-DIR]
* `--platform <platform>`: Add the platform to the build (takes precedence over --os and --arch)
* `--progress <type>`: Progress type (format: auto|plain|tty)] (default: auto)
* `-q, --quiet`: Suppress build output
* `-t, --tag <name>`: Name for the built image
* `-t, --tag <name>`: Name for the built image (can be specified multiple times)
* `--target <stage>`: Set the target build stage
* `--vsock-port <port>`: Builder shim vsock port (default: 8088)
* `--version`: Show the version.
@@ -122,6 +122,9 @@ container build --build-arg NODE_VERSION=18 -t my-app .
# build the production stage only and disable cache
container build --target production --no-cache -t my-app:prod .
# build with multiple tags
container build -t my-app:latest -t my-app:v1.0.0 -t my-app:stable .
```
## Container Management