gitmyhub

baseimage-docker

Shell ★ 9.1k updated 8h ago

A minimal Ubuntu base image modified for Docker-friendliness

A minimal Ubuntu 24.04 Docker base image that fixes process management, logging, and service supervision issues that occur when running Ubuntu inside containers, so you can focus on your application.

ShellDockerUbunturunitsetup: easycomplexity 3/5

When you run Ubuntu inside a Docker container, things break in subtle ways. Ubuntu was built for real machines or virtual servers, not containers. Its normal startup system expects hardware that is not there, and as a result containers accumulate stuck processes over time, logging stops working properly, and shutting down the container can corrupt files rather than close them cleanly. Baseimage-docker is a pre-built Docker image that fixes all of these problems before you write a single line of code.

The image is built on Ubuntu 24.04 and weighs about 8.3 MB of RAM at runtime. It adds a custom startup program called my_init that correctly handles the Unix process lifecycle inside a container, meaning it adopts any orphaned child processes and cleans them up properly. It also replaces Ubuntu's default service manager with runit, a lightweight tool that can supervise multiple services and automatically restart them if they crash. Together these two pieces let you run more than one background program inside a single container without fighting the Docker model.

Other additions include a syslog daemon so that the kernel and system tools can log messages normally, a cron scheduler for scheduled tasks, log rotation, and an optional SSH server (off by default) for logging into a running container to inspect what is happening. There is also a small utility called setuser that lets you run a command as a specific system user without elevated privileges.

The practical benefit is that you can use baseimage-docker as the FROM line in your own Dockerfile instead of the stock Ubuntu image, and all of the corner-case configuration work is already done. You can focus on installing your application rather than patching the operating system to behave correctly in a container. The project documentation walks through adding your own services, passing environment variables in, enabling SSH, and building the image yourself if you need custom modifications.

The full README is longer than what was shown.

Where it fits