Skip to content

[Bug]: Container build can't resolve default arguments #1766

Description

@InukVT

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

Try and build the following containerfile:

ARG TAG="${TAG:-latest}"
FROM docker.io/library/alpine:${TAG}
RUN echo ok

Problem description

When building with default args, I get the following error:

➜  mvp-error container build
[+] Building 0.0s (0/0)
Error: unknown (2): failed to solve: invalid ref: docker.io/library/alpine:${TAG}

Expected behaviour should match podman or docker where they use :latest tag for sample image:

➜  mvp-error docker build .
[+] Building 0.5s (6/6) FINISHED                                                                                                                                                                     docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                 0.0s
 => => transferring dockerfile: 111B                                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                                                     0.4s
 => [internal] load .dockerignore                                                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                                                      0.0s
 => [1/2] FROM docker.io/library/alpine:latest@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b                                                                                               0.0s
 => => resolve docker.io/library/alpine:latest@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b                                                                                               0.0s
 => CACHED [2/2] RUN echo ok                                                                                                                                                                                         0.0s
 => exporting to image                                                                                                                                                                                               0.0s
 => => exporting layers                                                                                                                                                                                              0.0s
 => => exporting manifest sha256:3cfd1f1c63292a946d97d643b56cb230284724a6c3f884a80646fe68796b455a                                                                                                                    0.0s
 => => exporting config sha256:bc70131ba5c16c30df94fbaf4d61ac5f8160f70edfbfa36e79f99ce2747fd366                                                                                                                      0.0s
 => => exporting attestation manifest sha256:317c203aa45b3e782b2d7435ce09cde0219c98c2f6a0e1fd0dec79a3b8bb5a3f                                                                                                        0.0s
 => => exporting manifest list sha256:9282520c0e9a0ac0544cdd4f015aaec553a28854646fd024f25be758979d6882                                                                                                               0.0s
 => => naming to moby-dangling@sha256:9282520c0e9a0ac0544cdd4f015aaec553a28854646fd024f25be758979d6882                                                                                                               0.0s
 => => unpacking to moby-dangling@sha256:9282520c0e9a0ac0544cdd4f015aaec553a28854646fd024f25be758979d6882                                                                                                            0.0s

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/d2iqo4jqxllanvszslk56p8id

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview
➜  mvp-error podman build .
STEP 1/2: FROM docker.io/library/alpine:latest
STEP 2/2: RUN echo ok
ok
COMMIT
--> 3c0ea4ac2df7
3c0ea4ac2df7b582868a11ea54a8082ef302f2a32997f5e8a3a50554af5b0141

Environment

- OS: macOS 26.5.1 (25F80)
- Xcode: Version 26.5 (17F42)
- Container: container CLI version 0.6.0 (build: release, commit: a23bcf0)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions