I’m running Python in a Docker container that will be part of an automated process. This process tries to discover as much of the file as it can, one of them being if an archive is an exported Docker Image.
Is there a way in Python that can tell me if a file is an exported Docker image without the Docker engine being available?
I don’t know if there is a python library that can do it for you, but if you can read a tar file in Python, you should see something like this in the tar:
- json files with a 64 characters long name and the extension:
- folders with a 64 characters long name
- each folder has these files:
So you can at least try to detect it if you can’t find a library. It will probbaly not be a perfect solution, since the content of the files could be incorrect, but is is very unlikely that you get this structure in a tar file which is not an exported image. This structure may change in the future of course.