{"id":24702543,"url":"https://github.com/yankeguo/minit","last_synced_at":"2026-03-16T11:31:53.246Z","repository":{"id":65193742,"uuid":"542958844","full_name":"yankeguo/minit","owner":"yankeguo","description":"The missing init daemon for container","archived":false,"fork":false,"pushed_at":"2025-11-13T10:05:54.000Z","size":1700,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-13T12:07:06.520Z","etag":null,"topics":["containers","docker","golang","init","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","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/yankeguo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"yankeguo","patreon":"yankeguo","buy_me_a_coffee":"yankeguo"}},"created_at":"2022-09-29T06:33:17.000Z","updated_at":"2025-11-13T10:05:59.000Z","dependencies_parsed_at":"2024-08-28T05:25:30.023Z","dependency_job_id":"f88067bb-62a4-4394-bd14-172b1ed12052","html_url":"https://github.com/yankeguo/minit","commit_stats":null,"previous_names":["yankeguo/minit","guoyk93/minit"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/yankeguo/minit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fminit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fminit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fminit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fminit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yankeguo","download_url":"https://codeload.github.com/yankeguo/minit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fminit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29931862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T09:58:13.507Z","status":"ssl_error","status_checked_at":"2026-02-28T09:57:57.047Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["containers","docker","golang","init","kubernetes"],"created_at":"2025-01-27T05:41:35.309Z","updated_at":"2026-02-28T11:35:01.385Z","avatar_url":"https://github.com/yankeguo.png","language":"Go","readme":"# minit\n\n![MIT License](https://img.shields.io/github/license/yankeguo/minit)\n[![release](https://github.com/yankeguo/minit/actions/workflows/release.yml/badge.svg)](https://github.com/yankeguo/minit/actions/workflows/release.yml)\n[![Dockerhub](https://img.shields.io/docker/pulls/yankeguo/minit)](https://hub.docker.com/r/yankeguo/minit)\n\nThe missing `init` daemon for container\n\n[中文文档](README.zh.md)\n\n## 1. Installation\n\nYou can install `minit` to your own container image by a multi-stage `Dockerfile`\n\n```dockerfile\nFROM yankeguo/minit:VERSION AS minit\n# Or using Github Packages\n# FROM ghcr.io/yankeguo/minit:VERSION AS minit\n\n# Your own build stage\nFROM ubuntu:22.04\n\n# ...\n\n# Copy minit binary\nCOPY --from=minit /minit /minit\n\n# Set ENTRYPOINT to minit\nENTRYPOINT [\"/minit\"]\n\n# Add a unit file to /etc/minit.d\nADD my-service.yml /etc/minit.d/my-service.yml\n```\n\n## 2. Unit Loading\n\n### 2.1 From Files\n\nAdd Unit `YAML` files to `/etc/minit.d`\n\nOverride default directory by environment variable `MINIT_UNIT_DIR`, multiple directories are supported by separating with `:`\n\nUse `---` to separate multiple units in single `YAML` file\n\n### 2.2 From Environment Variable\n\n#### Prefix with `MINIT_UNIT_XXXX_`\n\n**Example:**\n\n```dockerfile\nENV MINIT_UNIT_MAIN_COMMAND=\"redis-server /etc/redis.conf\"\nENV MINIT_UNIT_MAIN_DIR=\"/work\"\nENV MINIT_UNIT_MAIN_NAME=\"main-program\"\nENV MINIT_UNIT_MAIN_GROUP=\"super-main\"\nENV MINIT_UNIT_MAIN_KIND=\"cron\"\nENV MINIT_UNIT_MAIN_IMMEDIATE=true\nENV MINIT_UNIT_MAIN_CRON=\"* * * * *\"\nENV MINIT_UNIT_MAIN_CHARSET=gbk18030\n```\n\n#### DEPRECATED: `MINIT_MAIN`\n\n```dockerfile\nENV MINIT_MAIN=\"redis-server /etc/redis.conf\"\nENV MINIT_MAIN_DIR=\"/work\"\nENV MINIT_MAIN_NAME=\"main-program\"\nENV MINIT_MAIN_GROUP=\"super-main\"\nENV MINIT_MAIN_KIND=\"cron\"\nENV MINIT_MAIN_IMMEDIATE=true\nENV MINIT_MAIN_CRON=\"* * * * *\"\nENV MINIT_MAIN_CHARSET=gbk18030\n```\n\n### 2.3 From Command Arguments\n\n**Example:**\n\n```dockerfile\nENTRYPOINT [\"/minit\"]\nCMD [\"redis-server\", \"/etc/redis.conf\"]\n```\n\n### 2.4 Unit Order\n\nFor `render` and `once` units, `minit` will load them in a specific order\n\n**Source Order**\n\n- Units loaded from files\n- Units loaded from environment variables\n- Units loaded from command arguments\n\n**Type Order**\n\n- `render`\n- `once`\n\n**Order in Same Type**\n\n- Order in files\n- Order in environment variables\n\n**Override**\n\nSet field `order` to override default order.\n\n`order` is an integer, lower value will be loaded first.\n\n`order` with minus value will be loaded before default order.\n\n`order` with positive value will be loaded after default order.\n\n## 3. Unit Types\n\n### 3.1 Type: `render`\n\n`render` units execute at the very first stage. It renders template files.\n\nSee [pkg/mtmpl/funcs.go](pkg/mtmpl/funcs.go) for available functions.\n\n**Example:**\n\n- `/etc/minit.d/render-demo.yaml`\n\n```yaml\nkind: render\nname: render-demo\nfiles:\n  - /opt/*.txt # inline rendering\n  - /opt/source.txt:/opt/target.txt # file-to-file or dir-to-dir\n  - /opt/source/dir:*.txt:/opt/target/dir # source dir to target dir (three parts)\n```\n\n- `/opt/demo.txt`\n\n```text\nHello, {{stringsToUpper .Env.HOME}}\n```\n\nUpon startup, `minit` will render file `/opt/demo.txt`\n\nSince default user for container is `root`, the content of file `/opt/demo.txt` will become:\n\n```text\nHello, ROOT\n```\n\n### 3.2 Type: `once`\n\n`once` units execute after `render` units. It runs command once.\n\n**Example:**\n\n```yaml\nkind: once\nname: once-demo\ncommand:\n  - echo\n  - once\n```\n\n**Non-blocking**\n\nBy default, `once` units will block other `minit` units until finished.\n\nSet `blocking: false` to run `once` units in background.\n\n**Critical**\n\nIf `critical` field is set to `true`, `minit` will stop if this unit failed.\n\n### 3.3 Type: `daemon`\n\n`daemon` units execute after `render` and `once`. It runs long-running command.\n\n**Example:**\n\n```yaml\nkind: daemon\nname: daemon-demo\ncommand:\n  - sleep\n  - 9999\n```\n\n### 3.4 Type: `cron`\n\n`cron` units execute after `render` and `once`. It runs command at cron basis.\n\n**Example:**\n\n```yaml\nkind: cron\nname: cron-demo\ncron: \"* * * * *\" # cron expression, support extended syntax by https://github.com/robfig/cron\nimmediate: true # execute once on started\ncommand:\n  - echo\n  - cron\n```\n\nenvironment variable substitution is supported in `cron` field, for example:\n\n```yaml\ncron: $MY_SCHEDULE\n```\n\n## 4. Unit Features\n\n### 4.1 Replicas\n\nIf `count` field is set, `minit` will replicate this unit with sequence number suffixed\n\n**Example:**\n\n```yaml\nkind: once\nname: once-demo-replicas\ncount: 2\ncommand:\n  - echo\n  - $MINIT_UNIT_SUB_ID\n```\n\nIs equal to:\n\n```yaml\nkind: once\nname: once-demo-replicas-1\ncommand:\n  - echo\n  - 1\n---\nkind: once\nname: once-demo-replicas-2\ncommand:\n  - echo\n  - 2\n```\n\n### 4.2 Logging\n\n**Log Files**\n\nBy default `minit` only streams console logs of every command unit into it's own stdout/stderr.\n\nSet `MINIT_LOG_DIR` to enable file logging, for example: `MINIT_LOG_DIR=/var/log/minit`\n\n**Console Encoding**\n\nIf `charset` field is set, `minit` will transcode command console output from other encodings to `utf8`\n\n**Example:**\n\n```yaml\nkind: once\nname: once-demo-transcode\ncharset: gbk # supports gbk, gb18030 only\ncommand:\n  - command-that-produces-gbk-logs\n```\n\n### 4.3 Extra Environment Variables\n\nIf `env` field is set, `minit` will append extra environment variables while launching command.\n\n**Example:**\n\n```yaml\nkind: daemon\nname: daemon-demo-env\nenv:\n  AAA: BBB\ncommand:\n  - echo\n  - $AAA\n```\n\n### 4.4 Render Environment Variables\n\nAny environment with prefix `MINIT_ENV_` will be rendered before passing to command.\n\n**Example:**\n\n```yaml\nkind: daemon\nname: daemon-demo-render-env\nenv:\n  MINIT_ENV_MY_IP: '{{netResolveIP \"google.com\"}}'\ncommand:\n  - echo\n  - $MY_IP\n```\n\n### 4.5 Using `shell` in command units\n\nBy default, `command` field will be passed to `exec` syscall, `minit` won't modify ti, except simple environment variable substitution.\n\nIf `shell` field is set, `command` field will act as a simple script file.\n\n**Example:**\n\n```yaml\nkind: once\nname: once-demo-shell\nshell: \"/bin/bash -eu\"\ncommand: # this is merely a script file\n  - if [ -n \"${HELLO}\" ]; then\n  - echo \"world\"\n  - fi\n```\n\n### 4.6 Unit Enabling / Disabling\n\n**Grouping**\n\nUse `group` field to set a group name to units.\n\nDefault unit group name is `default`\n\n**Allowlist Mode**\n\nIf environment `MINIT_ENABLE` is set, `minit` will run in **Allowlist Mode**, only units with name existed\nin `MINIT_ENABLE` will be loaded.\n\nUse format `@group-name` to enable a group of units\n\nUse format `\u0026daemon` to enable a kind of units\n\nExample:\n\n```text\nMINIT_ENABLE=once-demo,@demo\n```\n\n**Denylist Mode**\n\nIf environment `MINIT_DISABLE` is set, `minit` will run in **Denylist Mode**, units with name existed in `MINIT_DISABLE`\nwill NOT be loaded.\n\nUse format `@group-name` to disable a group of units\n\nExample:\n\n```text\nMINIT_DISABLE=once-demo,@demo\n```\n\n## 4.7 Critical Units\n\nIf `critical` field is set to `true`, `minit` will stop if this unit failed.\n\nBy specifying the `success_codes` field for `once`, `daemon` and `cron` units, `minit` will interpret exit codes within the provided list as indicative of success.\n\nExample:\n\n```yaml\nkind: once\nname: once-demo-critical\ncritical: true\ncommand:\n  - false\n---\nkind: once\nname: once-demo-critical\ncritical: true\nsuccess_codes:\n  - 0\n  - 1\ncommand:\n  - false\n```\n\n## 5. Extra Features\n\n### 5.1 Zombie Processes Cleaning\n\nWhen running as `PID 1`, `minit` will do zombie process cleaning\n\nThis is the responsibility of `PID 1`\n\n### 5.2 Quick Exit\n\nBy default, `minit` will keep running even without `daemon` or `cron` units defined.\n\nIf you want to use `minit` in `initContainers` or outside of container, you can set envrionment\nvariable `MINIT_QUIT_EXIT=true` to let `minit` exit as soon as possible\n\n### 5.3 Resource limits (ulimit)\n\n**Warning: this feature need container running at Privileged mode**\n\nUse environment variable `MINIT_RLIMIT_XXX` to set resource limits\n\n- `unlimited` means no limitation\n- `-` means unchanged\n\n**Supported:**\n\n```text\nMINIT_RLIMIT_AS\nMINIT_RLIMIT_CORE\nMINIT_RLIMIT_CPU\nMINIT_RLIMIT_DATA\nMINIT_RLIMIT_FSIZE\nMINIT_RLIMIT_LOCKS\nMINIT_RLIMIT_MEMLOCK\nMINIT_RLIMIT_MSGQUEUE\nMINIT_RLIMIT_NICE\nMINIT_RLIMIT_NOFILE\nMINIT_RLIMIT_NPROC\nMINIT_RLIMIT_RTPRIO\nMINIT_RLIMIT_SIGPENDING\nMINIT_RLIMIT_STACK\n```\n\n**Example:**\n\n```text\nMINIT_RLIMIT_NOFILE=unlimited       # set soft limit and hard limit to 'unlimited'\nMINIT_RLIMIT_NOFILE=128:unlimited   # set soft limit to 128，set hard limit to 'unlimited'\nMINIT_RLIMIT_NOFILE=128:-           # set soft limit to 128，dont change hard limit\nMINIT_RLIMIT_NOFILE=-:unlimited     # don't change soft limit，set hard limit to 'unlimited'\n```\n\n### 5.4 Kernel Parameters (sysctl)\n\n**Warning: this feature need container running at Privileged mode**\n\nUse environment variable `MINIT_SYSCTL` to set kernel parameters\n\nSeparate multiple entries with `,`\n\n**Example:**\n\n```\nMINIT_SYSCTL=vm.max_map_count=262144,vm.swappiness=60\n```\n\n### 5.5 Transparent Huge Page (THP)\n\n**Warning: this feature need container running at Privileged mode and host `/sys` mounted**\n\nUse environment variable `MINIT_THP` to set THP configuration.\n\n**Example:**\n\n```\n# available values: never, madvise, always\nMINIT_THP=madvise\n```\n\n### 5.6 Built-in WebDAV server\n\nBy setting environment variable `MINIT_WEBDAV_ROOT`, `minit` will start a built-in WebDAV server at port `7486`\n\nEnvironment Variables:\n\n- `MINIT_WEBDAV_ROOT`, path to serve, `/srv` for example\n- `MINIT_WEBDAV_PORT`, port of WebDAV server, default to `7486`\n- `MINIT_WEBDAV_USERNAME` and `MINIT_WEBDAV_PASSWORD`, optional basic auth for WebDAV server\n\n### 5.7 Banner file\n\nBy putting a file at `/etc/banner.minit.txt`, `minit` will print it's content at startup\n\n## 6. Credits\n\nGUO YANKE, MIT License\n","funding_links":["https://github.com/sponsors/yankeguo","https://patreon.com/yankeguo","https://buymeacoffee.com/yankeguo"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyankeguo%2Fminit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyankeguo%2Fminit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyankeguo%2Fminit/lists"}