{"id":13416490,"url":"https://github.com/wemake-services/docker-image-size-limit","last_synced_at":"2025-06-16T06:03:35.962Z","repository":{"id":48316384,"uuid":"173497847","full_name":"wemake-services/docker-image-size-limit","owner":"wemake-services","description":":whale: Keep an eye on your docker image size and prevent it from growing too big","archived":false,"fork":false,"pushed_at":"2025-06-03T08:00:59.000Z","size":967,"stargazers_count":125,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-09T12:41:32.107Z","etag":null,"topics":["ci","code-quality","devops","docker","docker-images","docker-linter","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/docker-image-size-limit/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wemake-services.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"wemake-services","custom":"https://boosty.to/sobolevn"}},"created_at":"2019-03-02T20:54:07.000Z","updated_at":"2025-06-03T08:00:54.000Z","dependencies_parsed_at":"2025-05-18T02:32:14.272Z","dependency_job_id":null,"html_url":"https://github.com/wemake-services/docker-image-size-limit","commit_stats":{"total_commits":258,"total_committers":5,"mean_commits":51.6,"dds":0.3682170542635659,"last_synced_commit":"2821896c247aba81be1941838cf845e03b1eb3de"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/wemake-services/docker-image-size-limit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fdocker-image-size-limit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fdocker-image-size-limit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fdocker-image-size-limit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fdocker-image-size-limit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wemake-services","download_url":"https://codeload.github.com/wemake-services/docker-image-size-limit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fdocker-image-size-limit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260109458,"owners_count":22960025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","code-quality","devops","docker","docker-images","docker-linter","python","python3"],"created_at":"2024-07-30T21:00:59.594Z","updated_at":"2025-06-16T06:03:35.935Z","avatar_url":"https://github.com/wemake-services.png","language":"Python","funding_links":["https://github.com/sponsors/wemake-services","https://boosty.to/sobolevn"],"categories":["Docker Images","Community Resources","Python","Building Images"],"sub_categories":["Linter","Deployment"],"readme":"# docker-image-size-limit\n\n[![wemake.services](https://img.shields.io/badge/%20-wemake.services-green.svg?label=%20\u0026logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC%2FxhBQAAAAFzUkdCAK7OHOkAAAAbUExURQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP%2F%2F%2F5TvxDIAAAAIdFJOUwAjRA8xXANAL%2Bv0SAAAADNJREFUGNNjYCAIOJjRBdBFWMkVQeGzcHAwksJnAPPZGOGAASzPzAEHEGVsLExQwE7YswCb7AFZSF3bbAAAAABJRU5ErkJggg%3D%3D)](https://wemake.services)\n[![Build status](https://github.com/wemake-services/docker-image-size-limit/workflows/test/badge.svg?branch=master\u0026event=push)](https://github.com/wemake-services/docker-image-size-limit/actions?query=workflow%3Atest)\n[![codecov](https://codecov.io/gh/wemake-services/docker-image-size-limit/branch/master/graph/badge.svg)](https://codecov.io/gh/wemake-services/docker-image-size-limit)\n[![Python Version](https://img.shields.io/pypi/pyversions/docker-image-size-limit.svg)](https://pypi.org/project/docker-image-size-limit/)\n[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)\n\nLimit your `docker` image size with a simple CLI command.\nPerfect to be used inside your CI process.\n\nRead the [announcing post](https://sobolevn.me/2019/03/announcing-docker-image-size-limit).\n\n\n## Installation\n\n```bash\npip install docker-image-size-limit\n```\n\nOr use our [Github Action](https://github.com/wemake-services/docker-image-size-limit#github-action) or [pre-built docker image](https://github.com/wemake-services/docker-image-size-limit#docker-image).\n\n\n## Usage\n\nWe support just a single command:\n\n```bash\n$ disl your-image-name:label 300MiB\nyour-image-name:label exceeds 300MiB limit by 114.4 MiB\n```\n\nAdd `--max-layers` flag to also lint the maximum amount of layers possible\nin your image:\n\n```bash\n# If your image has 7 layers:\n$ disl your-image-name:label 300MiB --max-layers=5\nyour-image-name:label exceeds 5 maximum layers by 2\n\n# If your image has 5 layers:\n$ disl your-image-name:label 300MiB --max-layers=5\n# ok!\n```\n\nAdd `--current-size` flag to show the current size your image:\n\n```bash\n$ disl your-image-name:label 300MiB --current-size\nyour-image-name:label size is 414.4 MiB\nyour-image-name:label exceeds 300MiB limit by 114.4 MiB\n```\n\n\nAdd `--exit-zero` flag to force the exit code to be 0 even if there are errors:\n\n```bash\n$ disl your-image-name:label 300MiB --exit-zero\nyour-image-name:label exceeds 300MiB limit by 114.4 MiB\n\n$ echo $?\n0\n```\n\nYou can combine all flags together:\n\n```bash\n$ disl your-image-name:label 300MiB --max-layers=5 --current-size --exit-zero\nyour-image-name:label size is 414.4 MiB\nyour-image-name:label exceeds 300MiB limit by 114.4 MiB\nyour-image-name:label exceeds 5 maximum layers by 2\n```\n\nRun `disl` as a module:\n\n```bash\n$ python -m docker_image_size_limit your-image-name:label 300MiB\nyour-image-name:label exceeds 300MiB limit by 114.4 MiB\n```\n\n\n\n## Options\n\nYou can specify your image as:\n\n- Image name: `python`\n- Image name with tag: `python:3.6.6-alpine`\n\nYou can specify your size as:\n\n- Raw number of bytes: `1024`\n- Human-readable megabytes: `30 MB` or `30 MiB`\n- Human-readable gigabytes: `1 GB` or `1 GiB`\n- Any other size supported by [`humanfriendly`](https://humanfriendly.readthedocs.io/en/latest/api.html#humanfriendly.parse_size)\n\n\n## Programmatic usage\n\nYou can also import and use this library as `python` code:\n\n```python\nfrom docker import from_env\nfrom docker_image_size_limit import check_image_size\n\noversize = check_image_size(from_env(), 'image-name:latest', '1 GiB')\nassert oversize \u003c 0, 'Too big image!'  # negative oversize - is a good thing!\n```\n\nWe also ship [PEP-561](https://www.python.org/dev/peps/pep-0561/)\ncompatible type annotations with this library.\n\n\n## GitHub Action\n\nYou can also use this check as a [GitHub Action](https://github.com/marketplace/actions/docker-image-size-limit):\n\n```yaml\n- uses: wemake-services/docker-image-size-limit@master\n  with:\n    image: \"$YOUR_IMAGE_NAME\"\n    size: \"$YOUR_SIZE_LIMIT\"\n    # optional fields:\n    max_layers: 5\n    show_current_size: false\n    exit_zero: false\n```\n\nHere's [an example](https://github.com/wemake-services/docker-image-size-limit/actions?query=workflow%3Adisl).\n\n\n## Docker Image\n\nWe have a [pre-built image](https://hub.docker.com/r/wemakeservices/docker-image-size-limit) available.\n\nFirst, pull our pre-built docker image:\n\n```bash\ndocker pull wemakeservices/docker-image-size-limit\n```\n\nThen you can use it like so:\n\n```bash\ndocker run -v /var/run/docker.sock:/var/run/docker.sock --rm \\\n  -e INPUT_IMAGE=\"$YOUR_IMAGE_NAME\" \\\n  -e INPUT_SIZE=\"$YOUR_SIZE_LIMIT\" \\\n  -e INPUT_MAX_LAYERS=\"$YOUR_MAX_LAYERS\" \\\n  -e INPUT_SHOW_CURRENT_SIZE=\"true\" \\\n  -e INPUT_EXIT_ZERO=\"true\" \\\n  wemakeservices/docker-image-size-limit\n```\n\n\n## Should I use it?\n\nYou can use this script instead:\n\n```bash\nLIMIT=1024  # adjust at your will\nIMAGE='your-image-name:latest'\n\nSIZE=\"$(docker image inspect \"$IMAGE\" --format='{{.Size}}')\"\ntest \"$SIZE\" -gt \"$LIMIT\" \u0026\u0026 echo 'Limit exceeded'; exit 1 || echo 'Ok!'\n```\n\nBut I prefer to reuse tools over\ncustom `bash` scripts here and there.\n\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwemake-services%2Fdocker-image-size-limit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwemake-services%2Fdocker-image-size-limit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwemake-services%2Fdocker-image-size-limit/lists"}