Skip to content

fix(build): make --tag optional and repeatable, matching Docker - #96

Open
BluPix wants to merge 1 commit into
us:mainfrom
BluPix:fix/build-optional-repeatable-tag
Open

BluPix wants to merge 1 commit into
us:mainfrom
BluPix:fix/build-optional-repeatable-tag

Conversation

@BluPix

@BluPix BluPix commented Oct 17, 2026

Copy link
Copy Markdown

Problem

mocker build declares -t/--tag as a single, required option. That breaks two everyday Docker usages:

$ mocker build .
Error: Missing expected argument '--tag <tag>'

$ mocker build -t app:1.0 -t app:latest .
...
Successfully tagged app:latest      # app:1.0 is never created

In Docker, -t is optional and can be repeated. container build supports both as well: it accepts repeated -t, and without -t it names the image after a random UUID. Only mocker's option declaration got in the way.

Change

  • Build.tag is now [String], so -t can be omitted or repeated. The extra tags are passed through a new extraTags: parameter (default []) on ImageManager.build / makeBuildArguments as additional -t flags. Existing callers are unchanged.
  • When no -t is given, mocker picks the same <uuid>:latest name that container build would use. Mocker chooses the name itself so it can still look up the built image and report its ID.
  • Successfully tagged is printed once per tag given on the command line, and not at all for an untagged build, as in Docker.

Tests

  • New unit tests:
    • CLI: --tag is optional and repeatable.
    • Argument builder: extra tags become additional -t flags.
  • swift build and swift test pass.
  • Tried by hand against container 1.5.0:
    • mocker build . builds and stores <uuid>:latest.
    • mocker build -t a:1 -t b:2 . creates both tags on the same digest.

Separately, mocker build -q hangs. That is upstream in container build -q (apple/container#2387, fix in apple/container#2388), not in this change.

🤖 Generated with Claude Code

`mocker build` declared `-t/--tag` as a single required option, so the
everyday `docker build .` failed with "Missing expected argument
'--tag <tag>'", and `-t app:1.0 -t app:latest` silently kept only the
last tag. `container build` itself supports both: repeated `-t`, and no
`-t` at all (it names the image after a random UUID).

- `-t` is now optional and repeatable; extra tags are forwarded to
  `container build` as additional `-t` flags.
- Without `-t`, mocker picks the same `<uuid>:latest` name `container
  build` would, so the built image can still be looked up afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@us

us commented Oct 17, 2026

Copy link
Copy Markdown
Owner

hey @BluPix thanks for this great pr, will review soon and merge!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants