Skip to content

Commit

Permalink
Image execution problem has been fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntolog committed Oct 24, 2016
1 parent 3b5eecf commit 447faa0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
Binary file modified bin/linux_amd64/gef-docker
Binary file not shown.
12 changes: 10 additions & 2 deletions src/github.com/eudat-gef/gef-docker/dckr/dckr.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,27 +249,35 @@ func (c *Client) BuildImage(dirpath string) (Image, error) {
// ExecuteImage takes a docker image, creates a container and executes it
func (c Client) ExecuteImage(id ImageID, binds []string) (ContainerID, error) {
img, err := c.c.InspectImage(string(id))
log.Println("img", img)
if err != nil {
return ContainerID(""), err
}
hc := docker.HostConfig{
Binds: binds,
}
log.Println("Config", img.Config);
log.Println("binds", hc.Binds);
cco := docker.CreateContainerOptions{
Name: "",
Config: img.Config,
Config: &docker.Config{Image: img.ID},

HostConfig: &hc,
}
// fmt.Println("container options", cco)
fmt.Println("container options", cco)
cont, err := c.c.CreateContainer(cco)
if err != nil {
log.Println("Create contianer failed")
return ContainerID(""), err
}

err = c.c.StartContainer(cont.ID, &hc)
return ContainerID(cont.ID), err
}




// ListContainers lists the docker images
func (c Client) ListContainers() ([]Container, error) {
conts, err := c.c.ListContainers(
Expand Down
26 changes: 26 additions & 0 deletions src/github.com/eudat-gef/gef-docker/server/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,32 @@ func (s *Server) inspectVolumeHandler(w http.ResponseWriter, r *http.Request) {



//imageName := "sha256:2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749"
imageID := "2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749"
//imageID2 := "0cc497676af005168f1a814923bd2050e9edcc4d4e6fd60a2478417c48603175"
/*image, err := s.docker.InspectImage(dckr.ImageID(imageID))
if err != nil {
Response{w}.ServerError("execute docker image: inspectImage: ", err)
}
binds, err := makeBinds(r, image)
if err != nil {
Response{w}.ServerError("execute docker image: binds: ", err)
return
}
logParam("binds", strings.Join(binds, " : "))
*/



containerID, err := s.docker.ExecuteImage(dckr.ImageID(imageID), []string{"/test:/test"})
fmt.Println("EXECUTE")
fmt.Println((dckr.ImageID(imageID)))
fmt.Println(containerID)
if err != nil {
Response{w}.ServerError("execute docker image: ", err)
return
}
//loc := apiRootPath + jobsAPIPath + "/" + string(containerID)


json.NewEncoder(w).Encode(volumeItems)
Expand Down

0 comments on commit 447faa0

Please sign in to comment.