Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I unset a Docker image label?

I've a Dockerfile starting with the official nginx image.

FROM nginx

And they set the maintainer label.

LABEL maintainer="NGINX Docker Maintainers <[email protected]>"

So, now my image appears to also be maintained by them.

$ docker image inspect example-nginx
...
        "Labels": {
            "maintainer": "NGINX Docker Maintainers <[email protected]>"
        },

The documentation mentions how to overwrite the label. But, so far, the best I can do is set it to an empty value.

LABEL maintainer=

$ docker image inspect example-nginx
...
        "Labels": {
            "maintainer": ""
        },

How do I completely remove or unset a label set by a parent image?

like image 778
Anthony Mastrean Avatar asked Jun 21 '18 22:06

Anthony Mastrean


1 Answers

Great question. I did some research and, as far as I know, it's not possible with the current Docker/Moby implementation. It's also a problem for other properties as well, as you can see here (the issue is from 2014!):

https://github.com/moby/moby/issues/3465

I know it's really annoying, but, if you really want to remove that you can try following this:

https://github.com/moby/moby/issues/3465#issuecomment-383416201

The person automatized this process with a Python script that seems to let you do what you want:

https://github.com/gdraheim/docker-copyedit

It appears to have the Remove Label operation (https://github.com/gdraheim/docker-copyedit/blob/92091ed4d7a91fda2de39eb3ded8dd280fe61a35/docker-copyedit.py#L304), that is what you want.

I don't know if it works (I haven't had time to test that), but I think it's worth trying.

like image 82
William Martins Avatar answered Oct 05 '22 18:10

William Martins