Docker, how to know what service a certain docker image has?

Multi tool use
Docker, how to know what service a certain docker image has?
As I understand, we can pull any docker images publicly available from a registry. We can also create our own docker images. Let's say I created a docker image where I customized the apps I want and installed their dependencies. I pushed the image to a public registry.
My question is, how would someone know what kind of service or apps that my image has? Or I came across some image in a registry but I don't know what service they have.
Can we in this case, retrieve the service information from Dockerfile or requirement.txt file? If we can, where can I find the Dockerfile and requirement.txt of images that others built?
2 Answers
2
As a general rule, there's no way to find this out from only the image. You can docker inspect
the image and see what its default entrypoint and command are, but an image doesn't come with its Dockerfile and doesn't necessarily have a requirements.txt
or setup.py
or Gemfile
or package.json
. If you're using a compiled language like Go, it's possible to build a Docker image that contains only the application, and not other niceties like a shell that aren't strictly necessary to just run it.
docker inspect
requirements.txt
setup.py
Gemfile
package.json
Often someone will have some other pointer to the image that will have more details. For instance, if an image's source is on GitHub, then often the GitHub project's README.md
file or its wiki will have more details about the image, and typically the Dockerfile
is in the project root directory. You can look up images on Docker Hub (that just have username/imagename
format without a registry prefix) on https://hub.docker.com/. But you need some sort of out-of-band data about the image like this.
README.md
Dockerfile
username/imagename
We can use docker history
command to get list of commands run to create this image. It will contain few hashes, if you have used multi stage builder.
docker history
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
That explains. Thank you!!
– Kenneth
Jul 3 at 0:21