Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segevfiner/dockerexec
An "os/exec" like interface for running a command in a container, and being able to easily interact with stdin, stdout, and other adjustments
https://github.com/segevfiner/dockerexec
docker go golang
Last synced: 5 days ago
JSON representation
An "os/exec" like interface for running a command in a container, and being able to easily interact with stdin, stdout, and other adjustments
- Host: GitHub
- URL: https://github.com/segevfiner/dockerexec
- Owner: segevfiner
- License: bsd-3-clause
- Created: 2022-01-31T09:03:40.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-01T21:32:05.000Z (3 months ago)
- Last Synced: 2024-10-25T02:50:18.699Z (19 days ago)
- Topics: docker, go, golang
- Language: Go
- Homepage: https://pkg.go.dev/github.com/segevfiner/dockerexec
- Size: 77.1 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
dockerexec
==========
[![Go Reference](https://pkg.go.dev/badge/github.com/segevfiner/dockerexec.svg)](https://pkg.go.dev/github.com/segevfiner/dockerexec)
[![Build & Test](https://github.com/segevfiner/dockerexec/actions/workflows/go.yml/badge.svg)](https://github.com/segevfiner/dockerexec/actions/workflows/go.yml)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
-----
```sh
$ go get github.com/segevfiner/dockerexec
```Example:
```go
package mainimport (
"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.