diff --git a/README.md b/README.md index 03474c5..f07fd70 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,12 @@ Why use baseimage-docker instead of doing everything yourself in Dockerfile? | Fixes APT incompatibilities with Docker | See https://github.com/dotcloud/docker/issues/1024. | | syslog-ng | A syslog daemon is necessary so that many services - including the kernel itself - can correctly log to /var/log/syslog. If no syslog daemon is running, a lot of important messages are silently swallowed.

Only listens locally. | | ssh server | Allows you to easily login to your container to inspect or administer things.

Password and challenge-response authentication are disabled by default. Only key authentication is allowed.
It allows an predefined key by default to make debugging easy. You should replace this ASAP. See instructions. | +| cron | The cron daemon must be running for cron jobs to work. | | [runit](http://smarden.org/runit/) | For service supervision and management. Much easier to use than SysV init and supports restarting daemons when they crash. Much easier to use and more lightweight than Upstart. | | `setuser` | A tool for running a command as another user. Easier to use than `su`, has a smaller attack vector than `sudo`, and unlike `chpst` this tool sets `$HOME` correctly. Available as `/sbin/setuser`. | +Baseimage-docker is very lightweight: it only consumes 4 MB of memory. + ## Using baseimage-docker as base image The image is called `phusion/baseimage`, and is available on the Docker registry. @@ -41,6 +44,9 @@ By default, it allows SSH access for the key in `image/insecure_key`. This makes # a list of version numbers. FROM phusion/baseimage: + # Set correct environment variables. + ENV HOME /root + # Remove authentication rights for insecure_key. RUN rm -f /root/.ssh/authorized_keys /home/*/.ssh/authorized_keys diff --git a/image/buildconfig b/image/buildconfig index b8c7780..0085fd0 100644 --- a/image/buildconfig +++ b/image/buildconfig @@ -1,2 +1,3 @@ export LC_ALL=C export DEBIAN_FRONTEND=noninteractive +minimal_apt_get_install='apt-get install -y --no-install-recommends' diff --git a/image/prepare.sh b/image/prepare.sh index 6a6c2e9..d6c562f 100755 --- a/image/prepare.sh +++ b/image/prepare.sh @@ -9,7 +9,7 @@ echo deb http://archive.ubuntu.com/ubuntu precise-updates main universe >> /etc/ apt-get update ## Install HTTPS support for APT. -apt-get install -y apt-transport-https +$minimal_apt_get_install apt-transport-https ## Fix some issues with APT packages. ## See https://github.com/dotcloud/docker/issues/1024 @@ -18,8 +18,8 @@ ln -s /bin/true /sbin/initctl ## Upgrade all packages. echo "initscripts hold" | dpkg --set-selections -apt-get upgrade -y +apt-get upgrade -y --no-install-recommends ## Fix locale. -apt-get install -y language-pack-en +$minimal_apt_get_install language-pack-en locale-gen en_US diff --git a/image/runit/cron b/image/runit/cron new file mode 100755 index 0000000..ddd0a0f --- /dev/null +++ b/image/runit/cron @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/sbin/cron -f diff --git a/image/system_services.sh b/image/system_services.sh index 3030dac..5715214 100755 --- a/image/system_services.sh +++ b/image/system_services.sh @@ -7,15 +7,15 @@ set -x cp /build/my_init /sbin/ ## Install runit. -apt-get install -y runit +$minimal_apt_get_install runit ## Install a syslog daemon. -apt-get install -y syslog-ng +$minimal_apt_get_install syslog-ng-core mkdir /etc/service/syslog-ng cp /build/runit/syslog-ng /etc/service/syslog-ng/run ## Install the SSH server. -apt-get install -y openssh-server +$minimal_apt_get_install openssh-server mkdir /var/run/sshd mkdir /etc/service/sshd cp /build/runit/sshd /etc/service/sshd/run @@ -26,3 +26,8 @@ mkdir -p /root/.ssh chmod 700 /root/.ssh chown root:root /root/.ssh cat /build/insecure_key.pub > /root/.ssh/authorized_keys + +## Install cron daemon. +$minimal_apt_get_install cron +mkdir /etc/service/cron +cp /build/runit/cron /etc/service/cron/run diff --git a/image/utilities.sh b/image/utilities.sh index ae70b9c..e47c4a4 100755 --- a/image/utilities.sh +++ b/image/utilities.sh @@ -4,7 +4,7 @@ source /build/buildconfig set -x ## Often used tools. -apt-get install -y curl less nano vim psmisc +$minimal_apt_get_install curl less nano vim psmisc ## This tool runs a command as another user and sets $HOME. cp /build/setuser /sbin/setuser