Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add idle image #18407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add idle image #18407

wants to merge 1 commit into from

Conversation

spurin
Copy link

@spurin spurin commented Feb 7, 2025

Hi,

This PR is to start the process of adding the idle docker image under the umbrella of Docker Library.

idle: A Purpose-Built, Ultra-Lightweight Container for Doing Nothing Efficiently

idle is an intentionally minimalist container image designed to remain running while consuming the absolute minimum amount of system resources. It serves as an alternative to commonly used lightweight images such as busybox or alpine, but with an even smaller footprint and a singular purpose - idling.

Designed for Docker, Kubernetes and containerised environments, idle is statically compiled into a scratch-based image, making it ultra-lightweight, multi-architecture compatible, and highly efficient. It provides a simple yet powerful solution for scenarios where a running container is required but does not need to perform any active tasks.

Why idle?

While various base images exist for running minimal workloads, there are very few options that are explicitly designed for idling with the least possible overhead. Existing solutions such as busybox, alpine, and even the Kubernetes pause container come with additional components, dependencies, or process management features that may be unnecessary for simple use cases.

idle is designed to fill this gap by:

  • Being as lightweight as possible: It is built on a scratch base, with no unnecessary libraries or runtime dependencies.
  • Using minimal system resources: The binary is statically compiled and stripped down to the essentials, reducing both memory and disk footprint.
  • Supporting multiple architectures: Prebuilt images are available for various platforms, ensuring compatibility across different containerised environments.
  • Gracefully handling shutdowns: It responds cleanly to SIGINT and SIGTERM, making it well-suited for Docker and Kubernetes deployments.

Use Cases

idle is particularly beneficial in the following scenarios:

1. Docker and Kubernetes Documentation & Examples

Many tutorials and examples require a placeholder container that simply runs without doing anything. idle serves as a perfect fit for such cases while keeping resource usage minimal.

2. Secrets Store CSI Driver & Volume Mounting

In Kubernetes, the Secrets Store CSI driver can sync secrets to Kubernetes, but requires a pod to mount the secret volume. idle is an ideal candidate for such scenarios, as it provides an ultra-lightweight, long-running container.

3. Placeholder Containers in CI/CD Pipelines

When testing or debugging workloads, sometimes an inactive container is required as a placeholder. Instead of using larger images, idle provides a more efficient alternative.

4. Alternative to the Kubernetes Pause Container

The pause container plays an integral role in Kubernetes, handling PID 1, namespace lifecycle management, and other functions. However, for situations where those features are not required, idle offers a simpler, smaller, and more efficient option.

Why Make idle an Official Docker Image?

By making idle an official Docker image, it would:

  • Provide the container community with a dedicated, purpose-built solution for scenarios requiring an idle container.
  • Offer a reliable and verified source for a container that does nothing efficiently.
  • Reduce reliance on alternative images that may contain unnecessary components, increasing security and efficiency.
  • Serve as a useful supplement in official Docker and Kubernetes documentation, where a minimal placeholder container is often required.

With its ultra-lightweight design, cross-architecture support, and intentional simplicity, idle is a highly beneficial addition to the official Docker image registry.

To help fill out a review checklist:

I am a Docker Captain and educator in Docker and Cloud Native. I actively promote Docker and best practices wherever possible. Whilst the repo has been created in a way where it is fun and entertaining, this project was designed to serve a much needed requirement. It was created out of of the frustration of frequently waiting 5-10 seconds for pods to start, that were literally doing nothing.

idle is published under The Unlicense

Checklist for Review:

NOTE: This checklist is intended for the use of the Official Images maintainers both to track the status of your PR and to help inform you and others of where we're at. As such, please leave the "checking" of items to the repository maintainers. If there is a point below for which you would like to provide additional information or note completion, please do so by commenting on the PR. Thanks! (and thanks for staying patient with us ❤️)

  • associated with or contacted upstream?
  • available under an OSI-approved license?
  • does it fit into one of the common categories? ("service", "language stack", "base distribution")
  • is it reasonably popular, or does it solve a particular use case well?
  • does a documentation PR exist? (should be reviewed and merged at roughly the same time so that we don't have an empty image page on the Hub for very long)
  • official-images maintainer dockerization review for best practices and cache gotchas/improvements (ala the official review guidelines)?
  • 2+ official-images maintainer dockerization review?
  • existing official images have been considered as a base? (ie, if foobar needs Node.js, has FROM node:... instead of grabbing node via other means been considered?)
  • if FROM scratch, tarballs only exist in a single commit within the associated history?
  • passes current tests? any simple new tests that might be appropriate to add? (https://github.com/docker-library/official-images/tree/master/test)

Copy link

github-actions bot commented Feb 7, 2025

Diff for 3e5d08a:
diff --git a/_bashbrew-arches b/_bashbrew-arches
index 8b13789..79acf81 100644
--- a/_bashbrew-arches
+++ b/_bashbrew-arches
@@ -1 +1,7 @@
-
+amd64
+arm32v6
+arm32v7
+arm64v8
+i386
+ppc64le
+s390x
diff --git a/_bashbrew-cat b/_bashbrew-cat
index bdfae4a..d41ac66 100644
--- a/_bashbrew-cat
+++ b/_bashbrew-cat
@@ -1 +1,6 @@
-Maintainers: New Image! :D (@docker-library-bot)
+Maintainers: James Spurin <james@spurin.com> (@spurin)
+GitRepo: https://github.com/spurin/idle.git
+
+Tags: 1.0.0, latest
+Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
+GitCommit: 4a532d3a158e05dbd422acf38bf01a3e0ad4bedb
diff --git a/_bashbrew-list b/_bashbrew-list
index e69de29..172fabc 100644
--- a/_bashbrew-list
+++ b/_bashbrew-list
@@ -0,0 +1,2 @@
+idle:1.0.0
+idle:latest
diff --git a/_bashbrew-list-build-order b/_bashbrew-list-build-order
index e69de29..a26b0f1 100644
--- a/_bashbrew-list-build-order
+++ b/_bashbrew-list-build-order
@@ -0,0 +1 @@
+idle:latest
diff --git a/idle_latest/Dockerfile b/idle_latest/Dockerfile
new file mode 100644
index 0000000..c58c91a
--- /dev/null
+++ b/idle_latest/Dockerfile
@@ -0,0 +1,24 @@
+# Stage 1: Build stage
+FROM alpine:latest AS build
+
+# Install necessary tools
+RUN apk add --no-cache gcc musl-dev
+
+# Set the working directory
+WORKDIR /app
+
+# Copy the C source file
+COPY idle.c ./
+
+# Universal compile command for all architectures
+RUN gcc -Os -nostartfiles -ffreestanding -fno-asynchronous-unwind-tables -fno-stack-protector -static -s -Wl,--gc-sections -fdata-sections -ffunction-sections -o idle idle.c && \
+    strip --strip-all idle
+
+# Stage 2: Minimal final image
+FROM scratch
+
+# Copy the compiled binary from the build stage
+COPY --from=build /app/idle /idle
+
+# Set the binary as the entrypoint
+ENTRYPOINT ["/idle"]
diff --git a/idle_latest/idle.c b/idle_latest/idle.c
new file mode 100644
index 0000000..d5bc609
--- /dev/null
+++ b/idle_latest/idle.c
@@ -0,0 +1,28 @@
+#include <unistd.h>
+#include <time.h>
+#include <signal.h>
+#include <stdlib.h>
+
+static volatile int keep_running = 1;
+
+void handle_signal(int sig) {
+    keep_running = 0;
+}
+
+void _start() {
+    // Set up signal handlers for SIGTERM and SIGINT
+    struct sigaction sa;
+    sa.sa_handler = handle_signal;
+    sa.sa_flags = 0; // No special flags
+    sigemptyset(&sa.sa_mask);
+    sigaction(SIGTERM, &sa, NULL);
+    sigaction(SIGINT, &sa, NULL);
+
+    struct timespec ts = {1, 0}; // 1 second, 0 nanoseconds
+    while (keep_running) {
+        nanosleep(&ts, NULL);
+    }
+
+    // Exit cleanly
+    _exit(0);
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant