MaintainerDeprecated: Maintainer instruction is deprecated in favor of using label
is a build check warning, not an error: the build in the test finished with exit code 0.
Replace the MAINTAINER line with
LABEL org.opencontainers.image.authors="..." and the warning goes away.
The two lines store the name in different places of the image, so anything that reads the
old Author field needs to read the label instead. Both are shown below with
docker image inspect.
The error
#1 [internal] load build definition from Dockerfile
...
#1 WARN: MaintainerDeprecated: Maintainer instruction is deprecated in favor of using label (line 2)
...
1 warning found (use docker --debug to expand):
- MaintainerDeprecated: Maintainer instruction is deprecated in favor of using label (line 2)
exit code: 0
The terminal colour codes around "1 warning found" were removed from the capture above.
Why it happens
The Dockerfile had this line as its second instruction:
MAINTAINER Maria Garcia <maria.garcia@example.test>
The warning was printed in step #1, while the Dockerfile was loaded, and it names line 2.
The build then carried on through every step. The line still did something: it wrote the text
into the image's Author field and left the labels empty.
$ docker image inspect --format "{{.Author}} | {{json .Config.Labels}}" fix9-bld-c9
Maria Garcia <maria.garcia@example.test> | null
Read the warning as a note about the file, not about the image: the image built, its
steps ran and it was tagged fix9-bld-c9. Nothing has to change for the build
to work. The change is for the people who read the Dockerfile and for any tooling that
looks for the author in the labels.
The fix
FROM alpine:latest
LABEL org.opencontainers.image.authors="Maria Garcia <maria.garcia@example.test>"
WORKDIR /app
CMD ["sh"]
Rebuilt with docker build --progress=plain -t fix9-bld-c9 ., this file ended
with exit code: 0 and printed no warning. The same inspect command now shows
an empty Author and the name in the label:
$ docker image inspect --format "{{.Author}} | {{json .Config.Labels}}" fix9-bld-c9
| {"org.opencontainers.image.authors":"Maria Garcia <maria.garcia@example.test>"}
If a script or a registry page of yours reads .Author, point it at the label
when you make this change. Leaving the warning in place is the second-best choice: it did
not fail the build, but it adds a warning to the output of the build.
How it was reproduced
A four-line Dockerfile on alpine:latest (image id 294b683cb724) with a
MAINTAINER line holding a fictional name, built with
docker build --progress=plain -t fix9-bld-c9 . on Docker Desktop for Windows,
client and engine 29.9.3, buildx v0.38.1, then inspected with the command shown, rebuilt
under the same tag with the LABEL line and inspected again. The image
name is the test's own.
Frequently asked
- Does MaintainerDeprecated fail the docker build?
- No. It is a build check warning; in the test the build ended with exit code 0 and the image was created.
- What replaces MAINTAINER in a Dockerfile?
- A label: LABEL org.opencontainers.image.authors="Name <email>". In the test the warning was gone after the change.
- Where does MAINTAINER store the name in a Docker image?
- In the image's Author field. docker image inspect --format "{{.Author}}" printed it, while the labels were empty until the LABEL line replaced it.
More decoded errors in the Fixes category. Another build check warning with a one-line fix is LegacyKeyValueFormat.