selfcontainer

package
v1.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package selfcontainer detects the Docker container ID of the running process, so Miabi can recognise its own container and refuse to stop or delete it from the admin containers list — which would take the platform offline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detect

func Detect() string

Detect returns the ID of the container the process runs in, or "" when it is not running in a container (e.g. local development). Resolution order, most to least reliable:

  1. MIABI_CONTAINER_ID — an explicit operator/compose override.
  2. /proc/self/mountinfo — Docker bind-mounts /etc/hostname, /etc/hosts and /etc/resolv.conf from /var/lib/docker/containers/<id>/, giving the full ID.
  3. /proc/self/cgroup — the cgroup path carries the ID on cgroup v1.
  4. the hostname — Docker's default is the 12-char short ID.

func Match

func Match(a, b string) bool

Match reports whether two container references identify the same container, tolerating the mix of short (12-char) and full (64-char) IDs Docker returns. It requires at least a 12-char overlap to avoid accidental matches, so an empty reference never matches.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL