I want to get the manifest file of a docker image but unfortunately I cannot use docker. Is it possible to download it using curl?
The equivalent command with docker would be:
docker manifest inspect <image_name>
I'm looking for a way to find out which version of docker was used for a given image, to determine if a specific docker engine is causing an error when building the software.
docker image history IMAGE_ID doesn't give me the information I require.
The docker image inspect command has the DockerVersion field which is probably what you need:
docker image inspect IMAGE_ID
Output:
"DockerVersion": "19.03.11"
I have a docker image. I want to analyze the docker image history, for this I can use docker image history command in the docker installed environment.
But when am working in a Openshift cluster, I may not have the access to the docker command here. So here I want get the docker history command result for the given image.
So basically I have a docker image and I don't have docker installed there. In this case how can we get the history of that docker image?
Can anyone please help me on this?
You can get the registry info either via curl or skopeo inspect. But the rest of the metadata is stored inside the image itself so you do have to download at least the final layer.
Is there a way to see the Dockerfile that generated an image I downloaded, to use as a template for my own docker images?
Use
docker history --no-trunc IMAGE_NAME_OR_ID
This will show all commands run in the image building process in reverse order. It's not exactly a Dockerfile, but you can find all essential content.
Is it possible to get back the docker commands which were run to produce a given docker image? Since each line of a docker file should map to a single layer, it seems this would be possible, but I don't see anything in the docs.
docker history <image>
Does pretty much that.
Is it possible to get back the docker commands which were run to produce a given docker image?
No, considering you have commands like docker export / docker import which allows to flatten an image:
docker export <containerID> | docker import - <imagename>
The resulting image would be build from a container, and include only one layer. Not even a docker history would be able to give clues as to the original images and their Dockerfile which where part of the original container.
You can use combinations of two docker commands to achieve what you want:
docker inspect <image>
and
docker history <image>
Or you can use this cool service to see how that image being generated, each layer is a command in your docker file:
https://imagelayers.io/?images=java:latest,golang:latest,node:latest,python:latest,php:latest,ruby:latest
I guess it depends on where you got the image from.
In the case of these docker containers of mine from the Docker Hub you can use
this link from the right hand side of the webpage to follow it to this github repo containing the Dockerfile(s).
I do not think there is a command to "unassemble" a container / image and get back the instructions which made it.
For the images you create image metadata (labels) can be used to store Dockerfile
https://docs.docker.com/engine/userguide/labels-custom-metadata/
Initial solution was proposed here https://speakerdeck.com/garethr/managing-container-configuration-with-metadata
This approach of storing Dockerfile is not very efficient - it requires container to be started in order to extract the Dockerfile.
I personally use different approach - encode Dockerfile with Base64 and pass such encoded string using external arguments to set image label. This way you can read content of Dockerfile directly from image using inspect.
You can find detailed example here: https://gist.github.com/lruslan/3dea3b3d52a66531b2a1