mendhak / docker-http-https-echo

Docker image that echoes request data as JSON; listens on HTTP/S, useful for debugging.
https://code.mendhak.com/docker-http-https-echo/
MIT License
621 stars 136 forks source link

feature: add opencontainers label to the docker image #45

Closed mikaello closed 1 year ago

mikaello commented 1 year ago

Request: Make distributed docker image contain org.opencontainers.image.source label for easy reference back to this repository when mendhak/http-https-echo image gets updates.

We are building a custom image off of mendhak/http-https-echo, and we are using automatic tools to update the version of that base image, and those tools can create better pull request with more metadata if this is found is standardised labels.

It is some other pre-defined OCI keys, but org.opencontainers.image.source should be the correct one.

mendhak commented 1 year ago

@mikaello like this? https://github.com/mendhak/docker-http-https-echo/pull/46

I've also pushed a test tag :issue45-labels if you want to test.

mikaello commented 1 year ago

@mikaello like this? #46

Exactly (or almost, minor change commented in PR), thanks a lot for your swift reply!

I've also pushed a test tag :issue45-labels if you want to test.

Currently the labels are not in the final build, as mentioned in the PR:

$ docker inspect mendhak/http-https-echo:issue45-labels --format '{{ .Config.Labels }}'
map[]
mendhak commented 1 year ago

Ah thanks for that command. OK I pushed a different tag now,

docker pull mendhak/http-https-echo:labels
docker inspect lscr.io/linuxserver/transmission --format '{{ .Config.Labels }}'

And this is the output I get

map[org.opencontainers.image.description:Docker image that echoes request data as JSON; listens on HTTP/S, with various extra features, useful for debugging. org.opencontainers.image.documentation:https://github.com/mendhak/docker-http-https-echo/blob/master/README.md org.opencontainers.image.licenses:MIT org.opencontainers.image.source:https://github.com/mendhak/docker-http-https-echo org.opencontainers.image.title:http-https-echo org.opencontainers.image.url:https://github.com/mendhak/docker-http-https-echo]

Well it looks like a mapping of some sort. Looking better now?

mikaello commented 1 year ago

Looks very good! You can add json in the formatting string to get JSON:

$ docker inspect mendhak/http-https-echo:labels --format '{{json .Config.Labels }}' | jq
{
  "org.opencontainers.image.description": "Docker image that echoes request data as JSON; listens on HTTP/S, with various extra features, useful for debugging.",
  "org.opencontainers.image.documentation": "https://github.com/mendhak/docker-http-https-echo/blob/master/README.md",
  "org.opencontainers.image.licenses": "MIT",
  "org.opencontainers.image.source": "https://github.com/mendhak/docker-http-https-echo",
  "org.opencontainers.image.title": "http-https-echo",
  "org.opencontainers.image.url": "https://github.com/mendhak/docker-http-https-echo"
}
mendhak commented 1 year ago

Thanks again for that. :27 is now in Docker Hub.