ahmetb/go-dexec
À propos
Comme le package os/exec de Go, mais pour Docker. Et si vous pouviez exécuter des programmes à distance avec la même interface que os/exec ?
Systèmes et infrastructureProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
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.
Explorer des projets similaires
Chargement…