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 task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
You can use combinations of two docker commands to achieve what you want:
and
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
No, considering you have commands like
docker export
/docker import
which allows to flatten an image: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.Does pretty much that.