hostenv

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package hostenv tells whether mutti runs inside a container and maps paths of that container to paths on the Docker host, which is what the daemon needs for bind mounts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DockerSocket

func DockerSocket(getenv func(string) string, daemonHost string) string

DockerSocket returns the Docker socket's path on the Docker host, for containers that talk to Docker: $MUTTI_DOCKER_SOCKET if set (needed where mutti itself runs in a container), else the path of a unix daemon address like unix:///run/user/1000/docker.sock, else the default.

func SelfContainer

func SelfContainer(read FS) (id string, ok bool)

SelfContainer returns the id of the container mutti runs in, or ok=false on a plain host. The id comes from /proc/self/mountinfo, where Docker's per-container files show up; the hostname, Docker's default for it, is the fallback.

func SocketGID

func SocketGID(daemonHost string) (int, bool)

SocketGID returns the group owning the Docker socket of a daemon address like unix:///var/run/docker.sock; containers that talk to Docker need it (group_add).

Types

type FS

type FS func(path string) ([]byte, error)

FS is the part of the filesystem detection reads; the real one is os.ReadFile.

type PathMap

type PathMap struct {
	// contains filtered or unexported fields
}

PathMap translates paths inside this container to paths on the Docker host.

func NewPathMap

func NewPathMap(mounts []engine.Mount, extra map[string]string) *PathMap

NewPathMap builds a map from the container's mounts. Extra pairs (container path -> host path) win over the mounts, for runners that know better, like CI systems.

func (*PathMap) Lines

func (m *PathMap) Lines() []string

Lines returns the "a -> b" view of the map, for doctor.

func (*PathMap) ToHost

func (m *PathMap) ToHost(p string) (string, bool)

ToHost returns the host path of p, or ok=false when p is not on any mount (it only exists inside this container).

Jump to

Keyboard shortcuts

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