-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Example using go-dexec i'll probably demo...
package main
import (
"net/http"
"github.com/fsouza/go-dockerclient"
"log"
"github.com/ahmetalpbalkan/dexec"
"io"
"fmt"
)
func hello(w http.ResponseWriter, r *http.Request) {
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)
io.WriteString(w, fmt.Sprintf("%s", b))
}
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":8000", nil)
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels