{"id":15698016,"url":"https://github.com/felipecrs/docker-scripts","last_synced_at":"2025-05-08T21:14:01.038Z","repository":{"id":242150720,"uuid":"808819360","full_name":"felipecrs/docker-scripts","owner":"felipecrs","description":"Set of scripts to get useful information within docker containers.","archived":false,"fork":false,"pushed_at":"2025-01-03T00:22:18.000Z","size":29,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T21:13:35.467Z","etag":null,"topics":["cgroup","cgroups","container","containers","docker"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/felipecrs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["felipecrs"]}},"created_at":"2024-05-31T22:26:25.000Z","updated_at":"2025-04-14T18:10:41.000Z","dependencies_parsed_at":"2024-09-11T19:45:09.262Z","dependency_job_id":"4c8eb03e-5183-4fe7-ad0e-362dd0147ee3","html_url":"https://github.com/felipecrs/docker-scripts","commit_stats":null,"previous_names":["felipecrs/cgroups-scripts","felipecrs/cgroup-scripts","felipecrs/docker-scripts"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrs%2Fdocker-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrs%2Fdocker-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrs%2Fdocker-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrs%2Fdocker-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipecrs","download_url":"https://codeload.github.com/felipecrs/docker-scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149617,"owners_count":21861739,"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":["cgroup","cgroups","container","containers","docker"],"created_at":"2024-10-03T19:22:41.754Z","updated_at":"2025-05-08T21:14:01.003Z","avatar_url":"https://github.com/felipecrs.png","language":"Shell","funding_links":["https://github.com/sponsors/felipecrs"],"categories":[],"sub_categories":[],"readme":"# docker-scripts\n\nSet of scripts to get useful information within docker containers.\n\n## Usage\n\nAll `get_` scripts will print the requested information to `stdout`.\n\nAll `is_` scripts will return exit code `0` if the condition is met, and `1` otherwise.\n\nAny unexpected behavior will be printed to `stderr`.\n\nIf the `VERBOSE` environment variable is set to `true`, the scripts will print additional information to `stderr`.\n\nAdditionally, you can set the `DEBUG` environment variable to `true` to print debug information to `stderr`.\n\n## Installation\n\nYou can add the scripts to your images like this:\n\n```Dockerfile\nFROM alpine\n\nARG DOCKER_SCRIPTS_VERSION=0.2.0\nADD https://github.com/felipecrs/docker-scripts.git#v${DOCKER_SCRIPTS_VERSION}:scripts /opt/docker-scripts\n```\n\nAnd then, you can invoke any script calling it from `/opt/docker-scripts`:\n\n```console\n❯ docker run --rm --cpus 2 my-image /opt/docker-scripts/get_cpus.sh\n2\n```\n\n### `get_cpus.sh`\n\nIn a system with cgroup v2:\n\n```console\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true alpine sh\nVERBOSE(get_cpus.sh): cgroup v2 detected.\nVERBOSE(get_cpus.sh): No CPU limits set.\nVERBOSE(get_cpus.sh): CPUs:\n16\n\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 2 alpine sh\nVERBOSE(get_cpus.sh): cgroup v2 detected.\nVERBOSE(get_cpus.sh): CPUs:\n2\n\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 1.5 alpine sh\nVERBOSE(get_cpus.sh): cgroup v2 detected.\nVERBOSE(get_cpus.sh): CPUs:\n1\n\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 0.5 alpine sh\nVERBOSE(get_cpus.sh): cgroup v2 detected.\nVERBOSE(get_cpus.sh): CPUs:\n1\n```\n\nAnother system with cgroup v1:\n\n```console\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true alpine sh\nVERBOSE(get_cpus.sh): cgroup v1 detected.\nVERBOSE(get_cpus.sh): No CPU limits set.\nVERBOSE(get_cpus.sh): CPUs:\n8\n\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 2 alpine sh\nVERBOSE(get_cpus.sh): cgroup v1 detected.\nVERBOSE(get_cpus.sh): CPUs:\n2\n\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 1.5 alpine sh\nVERBOSE(get_cpus.sh): cgroup v1 detected.\nVERBOSE(get_cpus.sh): CPUs:\n1\n\n❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 0.5 alpine sh\nVERBOSE(get_cpus.sh): cgroup v1 detected.\nVERBOSE(get_cpus.sh): CPUs:\n1\n```\n\n### `get_memory.sh`\n\nIn a system with cgroup v2:\n\n```console\n❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true alpine sh\nVERBOSE(get_memory.sh): cgroup v2 detected.\nVERBOSE(get_memory.sh): No memory limits set.\nVERBOSE(get_memory.sh): Memory (MB):\n15996\n\n❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true --memory 1g alpine sh\nVERBOSE(get_memory.sh): cgroup v2 detected.\nVERBOSE(get_memory.sh): Memory (MB):\n1024\n```\n\nAnother system with cgroup v1:\n\n```console\n❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true alpine sh\nVERBOSE(get_memory.sh): cgroup v1 detected.\nVERBOSE(get_memory.sh): No memory limits set.\nMemory (MB):\n32092\n\n❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true --memory 1g alpine sh\nVERBOSE(get_memory.sh): cgroup v1 detected.\nVERBOSE(get_memory.sh): Memory (MB):\n1024\n```\n\n### `is_privileged.sh`\n\n```console\n❯ cat scripts/is_privileged.sh | docker run --rm -i -e VERBOSE=true alpine sh\nVERBOSE(is_privileged.sh): Container is not running in privileged mode.\n❯ echo $?\n1\n\n❯ cat scripts/is_privileged.sh | docker run --rm -i -e VERBOSE=true --privileged alpine sh\nVERBOSE(is_privileged.sh): Container is running in privileged mode.\n❯ echo $?\n0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipecrs%2Fdocker-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipecrs%2Fdocker-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipecrs%2Fdocker-scripts/lists"}