All Projects → nimmis → docker-alpine

nimmis / docker-alpine

Licence: other
Minimal Alpine with working init process

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to docker-alpine

docker-php7
A docker image with php 7 and extensions (apc, apcu, intl, mcrypt,...)
Stars: ✭ 16 (-23.81%)
Mutual labels:  alpine
admin-training
Galaxy Admin Training
Stars: ✭ 55 (+161.9%)
Mutual labels:  supervisor
docker-freescout
Dockerized Freescout Helpdesk
Stars: ✭ 92 (+338.1%)
Mutual labels:  alpine
balena-node-red
a node-red application with balena-supervisor support, can be managed remotely via balena publicURL
Stars: ✭ 54 (+157.14%)
Mutual labels:  supervisor
docker-alpine-sshd
A lightweight OpenSSH Docker Image built atop Alpine Linux.
Stars: ✭ 108 (+414.29%)
Mutual labels:  alpine
pi-factory
Bootstrap a bitcoin lightning box for Raspberry Pi 3 based on Alpine Linux
Stars: ✭ 17 (-19.05%)
Mutual labels:  alpine
docker-njs
Pure njs(Nginx JavaScript) Docker image, more convenient for development and debugging.
Stars: ✭ 16 (-23.81%)
Mutual labels:  alpine
docker-dind-awscli
A Docker image for Docker-in-Docker (dind) with AWS CLI v2 awscli tool included
Stars: ✭ 36 (+71.43%)
Mutual labels:  alpine
youtube-dl-docker
Download with youtube-dl using command line arguments or a configuration file + Automated updates
Stars: ✭ 44 (+109.52%)
Mutual labels:  alpine
varnish
Varnish docker container image
Stars: ✭ 55 (+161.9%)
Mutual labels:  alpine
php-mssql-alpine
Docker image with Microsoft SQL Server Driver into php image alpine
Stars: ✭ 28 (+33.33%)
Mutual labels:  alpine
mysqlclient
the mysqlclient Docker image (based on python:3.8.5-alpine3.12) https://github.com/PyMySQL/mysqlclient-python
Stars: ✭ 20 (-4.76%)
Mutual labels:  alpine
docker-php-base
Docker Base Image with PHP 7.4
Stars: ✭ 29 (+38.1%)
Mutual labels:  alpine
static-php-cli
Build single static PHP binary in linux, build with PHP project together, with Swoole and other popular extensions included.
Stars: ✭ 129 (+514.29%)
Mutual labels:  alpine
alpine-xmrig
XMRig miner in an Alpine Linux Docker image.
Stars: ✭ 35 (+66.67%)
Mutual labels:  alpine
mtproxy
Alpine-based Docker Image for Telegram MTProto Proxy
Stars: ✭ 89 (+323.81%)
Mutual labels:  alpine
docker-mongodb-backup
Docker MongoDB Backup Container based on Alpine w/S6 init, Zabbix Monitoring
Stars: ✭ 27 (+28.57%)
Mutual labels:  alpine
php
Generic PHP docker container images
Stars: ✭ 121 (+476.19%)
Mutual labels:  alpine
headless-chrome-alpine
A Docker container running headless Chrome
Stars: ✭ 26 (+23.81%)
Mutual labels:  alpine
docker-tinc
Docker Tinc VPN Mesh server w/S6 Overlay Init, Zabbix Monitoring, and distributed configuration updating based on Alpine
Stars: ✭ 35 (+66.67%)
Mutual labels:  alpine

microcontainer based on Alpine with working init process

This is a very small container (51 Mb) but still have a working init process, crond and syslog. This is the base image for all my other microcontainers

Why use this image

The unix process ID 1 is the process to receive the SIGTERM signal when you execute a

docker stop <container ID>

if the container has the command CMD ["bash"] then bash process will get the SIGTERM signal and terminate. All other processes running on the system will just stop without the possibility to shutdown correclty

my_init init script

In this container i have a scipt that handles the init process an uses the supervisor system to start the daemons to run and also catch signals (SIGTERM) to shutdown all processes started by supervisord. This is a modified version of an init script made by Phusion. I've modified it to use supervisor in stead of runit. There are also two directories to run scripts before any daemon is started.

Run script once /etc/my_runonce

All executable in this directory is run at start, after completion the script is removed from the directory

Run script every start /etc/my_runalways

All executable in this directory is run at every start of the container, ie, at docker run and docker start

Permanent output to docker log when starting container

Each time the container is started the content of the file /tmp/startup.log is displayed so if your startup scripts generate vital information to be shown please add that information to that file. This information can be retrieved anytime by executing docker logs <container id>

cron daemon

In many cases there are som need of things happening att given intervalls, default no cron processs is started in standard images. In this image cron is running together with logrotate to stop the logdfiles to be to big on log running containers.

rsyslogd

No all services works without a syslog daemon, if you don't have one running those messages is lost in space, all messages sent via the syslog daemon is saved in /var/log/syslog

Docker fixes

Also there are fixed (besideds the init process) assosiated with running linux inside a docker container.

New commands autostarted by supervisord

To add other processes to run automaticly, add a file ending with .conf in /etc/supervisor.d/ with a layout like this (/etc/supervisor.d/myprogram.conf)

[program:myprogram]
command=/usr/bin/myprogram

myprogram is the name of this process when working with supervisctl.

Output logs std and error is found in /var/log/supervisor/ and the files begins with the <-stdout|-stderr>superervisor*.log

For more settings please consult the manual FOR supervisor

starting commands from /etc/init.d/ or commands that detach with my_service

The supervisor process assumes that a command that ends has stopped so if the command detach it will try to restart it. To work around this problem I have written an extra command to be used for these commands. First you have to make a normal start/stop command and place it in the /etc/init.d that starts the program with

/etc/init.d/command start or
service command start

and stops with

    /etc/init.d/command stop or
    service command stop

Configure the configure-file (/etc/supervisor.d/myprogram.conf)

[program:myprogram]
command=/my_service myprogram

There is an optional parameter, to run a script after a service has start, e.g to run the script /usr/local/bin/postproc.sh av myprogram is started

    [program:myprogram]
    command=/my_service myprogram /usr/local/bin/postproc.sh

Output information to docker logs

The console output is owned by the my_init process so any output from commands woun't show in the docker log. To send a text from any command, either at startup och during run, append the output to the file /var/log/startup.log, e.g sending specific text to log

echo "Application is finished" >> /var/log/startup.log

or output from script

/usr/local/bin/myscript >> /var/log/startlog.log


> docker run -d --name alpine nimmis/alpine
> docker logs microbase
*** open logfile
*** Run files in /etc/my_runonce/
*** Run files in /etc/my_runalways/
*** Booting supervisor daemon...
*** Supervisor started as PID 6
2015-08-04 11:34:06,763 CRIT Set uid to user 0
*** Started processes via Supervisor......
crond                            RUNNING    pid 9, uptime 0:00:04
rsyslogd                         RUNNING    pid 10, uptime 0:00:04

> docker exec alpine sh -c 'echo "Testmessage to log" >> /var/log/startup.log'
> docker logs alpine
    *** open logfile
    *** Run files in /etc/my_runonce/
    *** Run files in /etc/my_runalways/
    *** Booting supervisor daemon...
    *** Supervisor started as PID 6
    2015-08-04 11:34:06,763 CRIT Set uid to user 0
    *** Started processes via Supervisor......
    crond                            RUNNING    pid 9, uptime 0:00:04
    rsyslogd                         RUNNING    pid 10, uptime 0:00:04

*** Log: Testmessage to log
    >

Installation

This continer should normaly run as a daemon i.e with the -d flag attached

docker run -d nimmis/alpine

but if you want to check if all services has been started correctly you can start with the following command

docker run -ti nimmis/alpine

the output, if working correctly should be

docker run -ti nimmis/alpine
*** open logfile
*** Run files in /etc/my_runonce/
*** Run files in /etc/my_runalways/
*** Booting supervisor daemon...
*** Supervisor started as PID 7
2015-01-02 10:45:43,750 CRIT Set uid to user 0
crond[10]: crond (busybox 1.24.1) started, log level 8
*** Started processes via Supervisor......
crond                            RUNNING    pid 10, uptime 0:00:04
rsyslogd                         RUNNING    pid 11, uptime 0:00:04

pressing a CTRL-C in that window or running docker stop <container ID> will generate the following output

*** Shutting down supervisor daemon (PID 7)...
*** Killing all processes...

you can the restart that container with

docker start <container ID>

Accessing the container with a shell can be done with

docker exec -ti <container ID> /bin/sh

TAGs

This image only contains the latest versions of Apline, the versions are nimmis/alpine: where tag is

Tag Alpine version size
latest latest/3.14
test latest/edge
3.14 3.14
3.13 3.13
3.12 3.12
3.11 3.11
3.10 3.10
3.9 3.9
3.8 3.8
3.7 3.7
3.6 3.6
3.5 3.5
3.4 3.4
3.3 3.3
3.2 3.2
3.1 3.1
edge edge
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].