dockerx

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dockerx contains utilities for working with docker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerPortToHostPort

func ContainerPortToHostPort(
	ctx context.Context,
	cli client.APIClient,
	containerID string,
	containerPort nat.Port,
) (int, error)

ContainerPortToHostPort finds the host port to which the given container port has been bound. Useful when starting test containers and allowing them to choose their own host port.

func MakeSystemAssignedPortMap

func MakeSystemAssignedPortMap(ports ...nat.Port) nat.PortMap

MakeSystemAssignedPortMap creates a port map for the given list of nat Ports, using system assigned ports for the host side of the port binding.

func MustMakeNATPort

func MustMakeNATPort(protocol, portRange string) nat.Port

MustMakeNATPort creates a new nat.Port, panicking rather than returning an error if the port is malformed. Useful for constants and tests.

func StreamContainerLogs

func StreamContainerLogs(ctx context.Context,
	cli client.APIClient, containerID string, log Logger,
	opts types.ContainerLogsOptions) (io.Closer, error)

StreamContainerLogs streams container logs in a background goroutine.

Types

type Logger

type Logger func(msg string)

A Logger logs output from the container.

func ZapLogger

func ZapLogger(log *zap.Logger) Logger

ZapLogger returns an adapter that passes container logs to a zap logger.

Jump to

Keyboard shortcuts

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