diff --git a/3.13/Dockerfile b/3.13/Dockerfile new file mode 100644 index 0000000..2034b91 --- /dev/null +++ b/3.13/Dockerfile @@ -0,0 +1,48 @@ +FROM alpine:3.13 + +MAINTAINER nimmis + +COPY root/. / + +RUN echo "@community http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \ + echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ + # read packages and update + apk update && apk upgrade && \ + # add packages + apk add ca-certificates rsyslog logrotate runit && \ + # Make info file about this build + mkdir -p /etc/BUILDS/ && \ + printf "Build of nimmis/alpine-micro:3.13, date: %s\n" `date -u +"%Y-%m-%dT%H:%M:%SZ"` > /etc/BUILDS/alpine-micro && \ + # install extra from github, including replacement for process 0 (init) + # add extra package for installation + apk add curl && \ + cd /tmp && \ + # Install utils and init process + curl -Ls https://github.com/nimmis/docker-utils/archive/master.tar.gz | tar xfz - && \ + ./docker-utils-master/install.sh && \ + rm -Rf ./docker-utils-master && \ + # Install backup support + curl -Ls https://github.com/nimmis/backup/archive/master.tar.gz | tar xfz - && \ + ./backup-master/install.sh all && \ + rm -Rf ./backup-master && \ + # remove extra packages + apk del curl && \ + # fix container bug for syslog + sed -i "s|\*.emerg|\#\*.emerg|" /etc/rsyslog.conf && \ + sed -i 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf && \ + sed -i 's/$KLogPermitNonKernelFacility on/#$KLogPermitNonKernelFacility on/' /etc/rsyslog.conf && \ + # remove cached info + rm -rf /var/cache/apk/* + +# Expose backup volume +VOLUME /backup + +# Set environment variables. +ENV HOME /root + +# Define working directory. +WORKDIR /root + +# Define default command. +CMD ["/boot.sh"] + diff --git a/3.13/README.md b/3.13/README.md new file mode 100644 index 0000000..c648000 --- /dev/null +++ b/3.13/README.md @@ -0,0 +1,180 @@ +## microcontainer based on Alpine with working init process +[![](https://images.microbadger.com/badges/image/nimmis/alpine-micro.svg)](https://microbadger.com/images/nimmis/alpine-micro "Get your own image badge on microbadger.com") + +This is a very small container (total 7.7 Mb) but still have a working init process, crond, syslog and logrotate. 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 + +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 + +### runit init process +In this container runit is used to handle starting and shuttning down processes automatically started + +#### Adding your own startscript inside a container + +Add a directory under the directory /etc/service/ that matches the process that should be started. Lets add a nginx start script to the container. First create the directory + + mkdir /etc/service/nginx + +and then create a file named `run` i that directory with the start code fpr nginx + + #!/bin/sh + exec 2>&1 + exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;" + +and make the file executable + + chmod +x /etc/service/nginx/run + +that command will be started automatically when the container is started. Be sure to start the command with flags that keeps it in the foreground otherwise runit will think that the process has ended and try to restart it. + +#### Adding it to the Dockerfile + +The above example is done in a Dockerfile by creating a file i the same directory as the Dockerfile +as nginx.sh containing the code + + #!/bin/sh + exec 2>&1 + exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;" + +and make the file executable + + chmod +x nginx.sh + +and add this lines to Dockerfile + + ADD nginx.sh /etc/service/nginx/run + +#### Environment variables in start script +If you need environment variables from the docker command line (-e,--env=[]) add + + source /etc/envvars + +before you use them in the script file + +In this container i have a scipt that handles the init process an uses the [supervisor system](http://supervisord.org/index.html) 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/runonce + +All executable in this directory is run at start, after completion the script is removed from the directory + +#### Run script every start /etc/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 ` + +### 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. + +### Installation + +This continer should normaly run as a daemon i.e with the `-d` flag attached + + docker run -d nimmis/alpine-micro + +Accessing the container with a shell can be done with + + docker exec -ti /bin/sh +This is the commands used inside nimmis/alpine based containers +for extra functionality + +#### set_tz + +In the default configuration Alpine is set to GMT time, if you need it +to use the corret time you can change to timezone for the container +with this command, syntax is + + set_tz + +To get list of available timezones do + + set_tz list + + +##### set timezone on startup + +Add the environment variable TIMEZONE to the desired timezone, i.e to set timezone to +CET Stockhome + + docker run -d -e TIMEZONE=Europa/Stockholm nimmis/alpine-micro + +##### set timezone in running container + +Execute the command on the container as + + docker exec -ti set_tz Europa/Stockholm + +##### get list of timezones before starting container + +Execute the following command, it will list available timezones and then +remove the container + + docker run --rm nimmis/alpine-micro set_tz list + +## Issues + +If you have any problems with or questions about this image, please contact us by submitting a ticket through a [GitHub issue](https://github.com/nimmis/docker-alpine-micro/issues "GitHub issue") + +1. Look to see if someone already filled the bug, if not add a new one. +2. Add a good title and description with the following information. + - if possible an copy of the output from **cat /etc/BUILDS/*** from inside the container + - any logs relevant for the problem + - how the container was started (flags, environment variables, mounted volumes etc) + - any other information that can be helpful + +## Contributing + +You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can. + +## TAGs + +This image only contains the latest versions of Apline, the versions are +nimmis/alpine-micro: where tag is + +| Tag | Alpine version | size | +| ------ | -------------- | ---- | +| latest | latest/3.10 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro.svg)](https://microbadger.com/images/nimmis/alpine-micro "Get your own image badge on microbadger.com") | +| 3.13 | 3.13 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.13.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.13 "Get your own image badge on microbadger.com") | +| 3.12 | 3.12 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.12.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.12 "Get your own image badge on microbadger.com") | +| 3.11 | 3.11 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.11.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.11 "Get your own image badge on microbadger.com") | +| 3.10 | 3.10 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.10.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.10 "Get your own image badge on microbadger.com") | +| 3.9 | 3.9 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.9.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.9 "Get your own image badge on microbadger.com") | +| 3.8 | 3.8 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.8.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.8 "Get your own image badge on microbadger.com") | +| 3.7 | 3.7 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.7.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.7 "Get your own image badge on microbadger.com") | +| 3.6 | 3.6 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.6.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.6 "Get your own image badge on microbadger.com") | +| 3.5 | 3.5 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.5.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.5 "Get your own image badge on microbadger.com") | +| 3.4 | 3.4 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.4.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.4 "Get your own image badge on microbadger.com") | +| 3.3 | 3.3 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.3.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.3 "Get your own image badge on microbadger.com") | +| 3.2 | 3.2 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.2.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.2 "Get your own image badge on microbadger.com") | +| 3.1 | 3.1 | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:3.1.svg)](https://microbadger.com/images/nimmis/alpine-micro:3.1 "Get your own image badge on microbadger.com") | +| edge | edge | [![](https://images.microbadger.com/badges/image/nimmis/alpine-micro:edge.svg)](https://microbadger.com/images/nimmis/alpine-micro:edge "Get your own image badge on microbadger.com") | + +## Contributors + + - Maximilien Richer + diff --git a/3.13/root/etc/run_always/.ignore b/3.13/root/etc/run_always/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/3.13/root/etc/run_once/00_dump_info.sh b/3.13/root/etc/run_once/00_dump_info.sh new file mode 100755 index 0000000..1e9291f --- /dev/null +++ b/3.13/root/etc/run_once/00_dump_info.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# +# Show information about container to standard output +# +# +# (c) 2017 nimmis +# + +cat /etc/BUILDS/* + diff --git a/tests/alpine-common.bats b/tests/alpine-common.bats index b0b824a..155c729 100755 --- a/tests/alpine-common.bats +++ b/tests/alpine-common.bats @@ -32,6 +32,10 @@ setup() { run docker run --rm $REPO:$TAG cat /etc/apk/repositories [ $status -eq 0 ] case $BRANCH in + v3.1[3-9]) + [ "${lines[0]}" = "https://dl-cdn.alpinelinux.org/alpine/$BRANCH/main" ] + [ "${lines[1]}" = "https://dl-cdn.alpinelinux.org/alpine/$BRANCH/community" ] + ;; v3.1|v3.2) [ "${lines[0]}" = "http://dl-cdn.alpinelinux.org/alpine/$BRANCH/main" ] [ "${lines[1]}" = "@community http://dl-4.alpinelinux.org/alpine/edge/community" ]