ahmetb/go-dexec
소개
Go의 os/exec 패키지와 비슷하지만 Docker용입니다. os/exec와 같은 인터페이스로 프로그램을 원격 실행할 수 있다면 어떨까요?
시스템 및 인프라측정된 스타 증가
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originaldexec 
dexec is a small Go library allowing you to run processes inside
Docker containers as if you are running them locally using os/exec package.
Read documentation at godoc.org or see examples.
Using dexec, you can do stream processing, off-load computationally
expensive parts of your program to a remote fleet of Docker engines.
Its interface is strikingly similar to os/exec.
Examples
Check out the following examples:
- Hello, world inside container →
- Connect to container’s
STDIN/STDOUT→ - Stream processing with pipes →
- Check exit code of a remote process →
- Audio extraction from YouTube videos →
- Parallel computation on Swarm →
A Short Example
It takes only a 4-line code change to convert a piece of code
using os/exec to use dexec to start running your stuff inside containers.
Here is a minimal Go program that runs echo in a container:
package main
import (
"log"
"github.com/ahmetalpbalkan/dexec"
"github.com/fsouza/go-dockerclient"
)
func main(){
cl, _ := docker.NewClient("unix:///var/run/docker.sock")
d := dexec.Docker{cl}
m, _ := dexec.ByCreatingContainer(docker.CreateContainerOptions{
Config: &docker.Config{Image: "busybox"}})
cmd := d.Command(m, "echo", `I am running inside a container!`)
b, err := cmd.Output()
if err != nil { log.Fatal(err) }
log.Printf("%s", b)
}
Output: I am running inside a container!
Use Cases
This library is intended for providing an execution model that looks and feels
like os/exec package.
You might want to use this library when:
You want to execute a process, but run it in a container with extra security and finer control over resource usage with Docker –and change your code minimally.
You want to execute a piece of work on a remote machine (or even better, a pool of machines or a cluster) through Docker. Especially useful to distribute computationally expensive workloads.
For such cases, this library abstracts out the details of executing the process in a container and gives you a cleaner interface you are already familiar with.
관련 프로젝트 살펴보기
불러오는 중…