podman icon indicating copy to clipboard operation
podman copied to clipboard

Problem with dollar signs in labels - `podman build --label 'test=$something' .`

Open maxnet opened this issue 5 months ago • 9 comments

Issue Description

Podman seems to handle labels with dollar signs different than Docker.

I am having the problem that I need to build an image that has a label with a dollar in it. With Docker the dollar is treated as-is, which is desired-, but it seems Podman treats it like a variable or something, resulting in a blank label. Have tried to escape with slashes or double dollars, but no such luck.

When using podman:

$ echo "FROM busybox" > Dockerfile
$ podman build -t test . --label 'test=$something'
STEP 1/2: FROM busybox
STEP 2/2: LABEL "test"="$something"
COMMIT test
--> e1d381555628
Successfully tagged localhost/test:latest
e1d38155562825539ff1da7eddef656dd7b4c9c86db642a0f8efa187a50852d5
$ docker inspect test
[...]
"Labels": {
"io.buildah.version": "1.43.1",
"test": ""
}
[...]

When using Docker:

$ echo "FROM busybox" > Dockerfile
$ docker build -t test --label 'test=$something' .

[+] Building 1.8s (5/5) FINISHED                                                                                                      docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                  0.0s
 => => transferring dockerfile: 50B                                                                                                                   0.0s
 => [internal] load metadata for docker.io/library/busybox:latest                                                                                     1.4s
 => [internal] load .dockerignore                                                                                                                     0.0s
 => => transferring context: 2B                                                                                                                       0.0s
 => [1/1] FROM docker.io/library/busybox:latest@sha256:fd8d9aa63ba2f0982b5304e1ee8d3b90a210bc1ffb5314d980eb6962f1a9715d                               0.2s
 => => resolve docker.io/library/busybox:latest@sha256:fd8d9aa63ba2f0982b5304e1ee8d3b90a210bc1ffb5314d980eb6962f1a9715d                               0.0s
 => => sha256:025fe1949698376d1d9a946f8a39a3529ad3ea540ca92b78c6cd041deb19d63e 1.92MB / 1.92MB                                                        0.2s
 => exporting to image                                                                                                                                0.3s
 => => exporting layers                                                                                                                               0.0s
 => => exporting manifest sha256:b15b925ce72e6758dda6a7f6588dc98585a8852d899bcb0416ef773e6d14ce51                                                     0.0s
 => => exporting config sha256:169ba401b1e475dc4dff5ccc58982ce025f3180c1c4c7c3e90ce07ebc31a46e2                                                       0.0s
 => => exporting attestation manifest sha256:ae1add153dc0b332f7f0b7459e6708a48f077288f3b77007294b53dfa81cd7d7                                         0.0s
 => => exporting manifest list sha256:3db12d787d4e9ecbe6d9678ce33323c72658d4f5690486c22ea400bdb7a523cd                                                0.0s
 => => naming to docker.io/library/test:latest                                                                                                        0.0s
 => => unpacking to docker.io/library/test:latest                                                                                                     0.3s
$ docker inspect test
[…]
            "Labels": {
                "test": "$something"
            },
[…]

Steps to reproduce the issue

Steps to reproduce the issue

  1. echo "FROM busybox" > Dockerfile
  2. podman build -t test . --label 'test=$something'
  3. docker inspect test

Describe the results you received

"Labels": { "io.buildah.version": "1.43.1", "test": "" }

Describe the results you expected

Expected to see a label "test": "$something"

podman info output

podman version
Client: Podman Engine
Version: 5.8.1
API Version: 5.8.1
Go Version: go1.26.1
Git Commit: c6077f645788743258a1a749f8005b4fb3cbe533
Built: Wed Mar 11 20:57:57 2026
Build Origin: pkginstaller
OS/Arch: darwin/arm64

Server: Podman Engine
Version: 5.8.2
API Version: 5.8.2
Go Version: go1.25.9 X:nodwarf5
Git Commit: 5b263b5f5b48004a87caac44e67349a8266d9ef4
Built: Mon Apr 13 02:00:00 2026
OS/Arch: linux/arm64

Podman in a container

Yes

Privileged Or Rootless

None

Upstream Latest Release

No

Additional environment details

Using Podman desktop on a Mac

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

maxnet avatar Jul 01 '26 12:07 maxnet

/assign

alter-yash avatar Jul 02 '26 11:07 alter-yash

starting to look into this

alter-yash avatar Jul 02 '26 11:07 alter-yash

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Aug 10 '26 02:08 github-actions[bot]

Hi iam taking this issue

Srujansa avatar Aug 11 '26 17:08 Srujansa

Are you still on this issue?

Amirali-Amirifar avatar Sep 03 '26 16:09 Amirali-Amirifar

Yes, I was tied up with a few things for the time being. I’ll be ramping up work on this issue starting this week.

alter-yash avatar Sep 07 '26 05:09 alter-yash

This looks like expected behavior, not a bug. --label is applied as a build LABEL step, so $name is handled like Dockerfile variable substitution: if name is not set in the build environment, expansion yields an empty string.

If you need a literal $ in the value, escape it (e.g. --label 'test=\$something'). For fixed label text, putting a LABEL line in the Containerfile is also fine.

I think we can close this issue. I think Docker, in this case, behaves incorrectly. PTAL @podman-container-tools/podman-maintainers

Honny1 avatar Oct 12 '26 15:10 Honny1

If you need a literal $ in the value, escape it (e.g. --label 'test=\$something')

As mentioned in the issue, I had no luck escaping it with slashes (nor with double dollars).

$ podman build -t test . --label 'test=\$something'
STEP 1/2: FROM busybox
Resolved "busybox" as an alias (/etc/containers/registries.conf.d/shortnames.conf)
Trying to pull docker.io/library/busybox:latest...
Getting image source signatures
Copying blob 37bb94b0940b done   | 
Copying config aaef90e065 done   | 
Writing manifest to image destination
STEP 2/2: LABEL "test"="\\$something"
COMMIT test
--> 921c4136ea6b
Successfully tagged localhost/test:latest
921c4136ea6b2679ef67f3b8588c4018bea050c3686c7588a7772366369bbfb0
$ podman inspect test
[
     {
          "Id": "921c4136ea6b2679ef67f3b8588c4018bea050c3686c7588a7772366369bbfb0",
          "Digest": "sha256:36b047270a00b5cff84a72e79cce3aab20313134c11ec1fb7b49b25bd95da8f5",
          "RepoTags": [
               "localhost/test:latest"
          ],
          "RepoDigests": [
               "localhost/test@sha256:36b047270a00b5cff84a72e79cce3aab20313134c11ec1fb7b49b25bd95da8f5"
          ],
          "Parent": "aaef90e065235eb0b2d9938be85d1b81add2902cf89affe2cdfa19be33476ac0",
          "Comment": "",
          "Created": "2026-10-12T18:26:08.991487338Z",
          "Config": {
               "Env": [
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
               ],
               "Cmd": [
                    "sh"
               ],
               "Labels": {
                    "io.buildah.version": "1.33.7",
                    "test": "\\"
               }
          },
[...]

(This is from a Linux box, but had the same issue with a newer podman version on my Mac)

maxnet avatar Oct 12 '26 18:10 maxnet

Oh I see, it seems I missed someting.

Honny1 avatar Oct 14 '26 14:10 Honny1