Skip to content

An "os/exec" like interface for running a command in a container, and being able to easily interact with stdin, stdout, and other adjustments

License

Notifications You must be signed in to change notification settings

segevfiner/dockerexec

Repository files navigation

dockerexec

Go Reference Build & Test

An "os/exec" like interface for running a command in a container, and being able to easily interact with stdin, stdout, and other adjustments.

Usage

$ go get github.com/segevfiner/dockerexec

Example:

package main

import (
    "fmt"

    "github.com/docker/docker/client"
    "github.com/segevfiner/dockerexec"
)

func main() {
    // You might want to use client.WithVersion in production
    dockerClient, err := client.NewClientWithOpts(client.WithAPIVersionNegotiation(), client.FromEnv)
    if err != nil {
        panic(err)
    }

    cmd := dockerexec.Command(dockerClient, "ubuntu:focal", "sh", "-c", "echo Hello, World!")
    output, err := cmd.Output()
    if err != nil {
        panic(err)
    }

    fmt.Printf("%s", output)
}

License

BSD-3-Clause.

About

An "os/exec" like interface for running a command in a container, and being able to easily interact with stdin, stdout, and other adjustments

Topics

Resources

License

Stars

Watchers

Forks

Languages