Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pablo-ruth/go-init
A minimal init system for containers with pre/post hooks
https://github.com/pablo-ruth/go-init
docker go golang init init-system
Last synced: about 15 hours ago
JSON representation
A minimal init system for containers with pre/post hooks
- Host: GitHub
- URL: https://github.com/pablo-ruth/go-init
- Owner: pablo-ruth
- License: mit
- Archived: true
- Created: 2017-11-03T18:25:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-27T16:56:20.000Z (3 months ago)
- Last Synced: 2024-08-27T18:40:41.957Z (3 months ago)
- Topics: docker, go, golang, init, init-system
- Language: Go
- Size: 9.77 KB
- Stars: 45
- Watchers: 3
- Forks: 17
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-init
⚠️ **Note: This repository is no longer maintained. A maintained fork is available at [https://github.com/adambkaplan/go-init](https://github.com/adambkaplan/go-init).**
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
[![Build Status](https://travis-ci.org/pablo-ruth/go-init.svg?branch=master)](https://travis-ci.org/pablo-ruth/go-init)**go-init** is a minimal init system with simple *lifecycle management* heavily inspired by [dumb-init](https://github.com/Yelp/dumb-init).
It is designed to run as the first process (PID 1) inside a container.
It is lightweight (less than 500KB after UPX compression) and statically linked so you don't need to install any dependency.
## Download
You can download the latest version on [releases page](https://github.com/pablo-ruth/go-init/releases)
## Why you need an init system
I can't explain it better than Yelp in *dumb-init* repo, so please [read their explanation](https://github.com/Yelp/dumb-init/blob/v1.2.0/README.md#why-you-need-an-init-system)
Summary:
- Proper signal forwarding
- Orphaned zombies reaping## Why another minimal init system
In addition to *init* problematic, **go-init** tries to solve another Docker flaw by adding *hooks* on start and stop of the main process.
If you want to launch a command before the main process of your container and another one after the main process exit, you can't with Docker, see [issue 6982](https://github.com/moby/moby/issues/6982)
With **go-init** you can do that with "pre" and "post" hooks.
## Usage
### one command
```
$ go-init -main "my_command param1 param2"
```### pre-start and post-stop hooks
```
$ go-init -pre "my_pre_command param1" -main "my_command param1 param2" -post "my_post_command param1"
```## docker
Example of Dockerfile using *go-init*:
```
FROM alpine:latestCOPY go-init /bin/go-init
RUN chmod +x /bin/go-init
ENTRYPOINT ["go-init"]
CMD ["-pre", "echo hello world", "-main", "sleep 5", "-post", "echo I finished my sleep bye"]
```Build it:
```
docker build -t go-init-example
```Run it:
```
docker run go-init-example
```