{"id":23451,"library":"container-inspector","title":"container-inspector","description":"Docker, containers, rootfs and virtual machine related software composition analysis (SCA) utilities. Current version 33.1.0, requires Python >=3.10. Released by AboutCode.org.","status":"active","version":"33.1.0","language":"python","source_language":"en","source_url":"https://github.com/aboutcode-org/container-inspector","tags":["docker","containers","SCA","software composition analysis","rootfs","layers"],"install":[{"cmd":"pip install container-inspector","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for unpacking and utilities","package":"commoncode","optional":false},{"reason":"File type detection","package":"typecode","optional":false}],"imports":[{"note":"Correct import path","symbol":"Image","correct":"from container_inspector.image import Image"},{"note":"Correct import path","symbol":"Layer","correct":"from container_inspector.layer import Layer"},{"note":"Correct import path","symbol":"rootfs_from_dir","correct":"from container_inspector.rootfs import rootfs_from_dir"},{"note":"image_from_archive is a function in image module, not top-level","wrong":"from container_inspector import image_from_archive","symbol":"image_from_archive"}],"quickstart":{"code":"import os\nfrom container_inspector.image import Image\nfrom container_inspector.utils import extract_tar\n\n# Replace with a real container image archive path\narchive = os.environ.get('DOCKER_ARCHIVE', '')\nif archive:\n    img = Image(archive)\n    print(f\"Image ID: {img.id}\")\n    print(f\"Layers: {len(img.layers)}\")\n    for layer in img.layers:\n        print(f\"  Layer digest: {layer.digest}\")","lang":"python","description":"Load a container image archive and inspect its layers."},"warnings":[{"fix":"Upgrade to Python 3.7+.","message":"Python 3.6 support dropped in v32.0.0.","severity":"breaking","affected_versions":">=32.0.0"},{"fix":"Set as_events=False to get list of error strings, or handle ExtractEvent objects.","message":"extract_tar now returns a list of ExtractEvent (or error strings) instead of just strings. Use as_events=False for old behavior.","severity":"breaking","affected_versions":">=32.0.0"},{"fix":"Use archive_location and extracted_location instead.","message":"parent_id and parent_digest attributes removed from Image.","severity":"deprecated","affected_versions":">=21.5.25"},{"fix":"Always import with underscores: import container_inspector","message":"The library name is container-inspector but import module uses underscores: container_inspector.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure the archive is a tar file containing manifest.json and layer tarballs.","message":"Docker archives must be in tarball format (e.g., docker save output).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"pip install container-inspector && import container_inspector","cause":"Pip installed the package as container-inspector but import uses underscores.","error":"ModuleNotFoundError: No module named 'container_inspector'"},{"fix":"Use archive_location or extracted_location instead.","cause":"parent_id was removed in version 21.5.25.","error":"AttributeError: 'Image' object has no attribute 'parent_id'"},{"fix":"Upgrade to >=31.0.0 or remove skip_symlinks argument.","cause":"skip_symlinks parameter added in v31.0.0; older version does not support it.","error":"TypeError: extract_tar() got an unexpected keyword argument 'skip_symlinks'"},{"fix":"Use a proper Docker image archive: docker save -o image.tar <image>","cause":"The provided archive is not a valid Docker image tarball (missing manifest.json).","error":"FileNotFoundError: [Errno 2] No such file or directory: 'manifest.json'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}