gocontainers

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 6 Imported by: 0

README

go-containers: Go Docker Containers package

tag Go Version GoDoc Build Status Go Report Card Coverage Contributors License

This Go package provides a simple interface for running Docker containers directly from a host system.

Features

  • Pull Docker Image: The RunContainerOnHost function pulls a Docker image from a Docker registry.
  • Create Docker Container: The function creates a Docker container from the pulled image.
  • Run Docker Container: It then runs the Docker container on the host.
  • Wait For Container To Complete: The function waits for the Docker container to finish its execution.
  • Fetch Logs: It fetches and prints the logs of the Docker container to os.Stdout.

Dependencies

This package uses the following dependencies:

  • context: Standard Go package for carrying deadlines, cancellations signals, and other request-scoped values across API boundaries.
  • github.com/docker/docker/api/types: Docker API types.
  • github.com/docker/docker/api/types/container: Docker container types.
  • github.com/docker/docker/client: Docker client to interact with Docker API.
  • io: Standard Go package for basic interfaces to I/O primitives.
  • os: Standard Go package that provides a platform-independent interface to operating system functionality.

Usage

package main

import (
	"github.com/zcubbs/gocontainers"
)

func main() {
	image := "ubuntu:latest"
	cmd := []string{"/bin/sh", "-c", "echo Hello, World"}

	err := gocontainers.RunContainerOnHost(image, cmd)
	if err != nil {
		panic(err)
	}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunContainerOnHost

func RunContainerOnHost(image string, cmd []string) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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