dockerdockerfile

How to specify a comment for the detailed info in docker


I am asking here how to write a comment in a dockerfile. So I need to be clear that I am not talking about writing

#This is a comment

into a dockerfile.

What I am looking for is how to set the comment field in the detailed description.

docker inspect ubuntu -f {{.Comment}}
docker inspect ubuntu

with either of these two commands you can see a comment entry in the detailed description. The current ubuntu container has an empty comment.

I checked the builder reference and did not find anything about it. I googled and stack-overflowed - unfortunately the keyword "comment" leads the search towards how to use #comment which is not what I am after.

My question is how can I populate a comment field in the detailed description?


Solution

  • Use docker commit command. See docs here:

    $ docker pull nginx
    $ docker image inspect -f {{.Comment}} nginx
    
    $ docker run -d --name mycontainer nginx
    $ docker commit -m "my comment" mycontainer nginx
    $ docker image inspect -f {{.Comment}} nginx
    my comment