github.com/rothwerx/packer@v0.9.0/builder/docker/step_commit.go (about) 1 package docker 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 "github.com/mitchellh/packer/packer" 7 ) 8 9 // StepCommit commits the container to a image. 10 type StepCommit struct { 11 imageId string 12 } 13 14 func (s *StepCommit) Run(state multistep.StateBag) multistep.StepAction { 15 driver := state.Get("driver").(Driver) 16 containerId := state.Get("container_id").(string) 17 ui := state.Get("ui").(packer.Ui) 18 19 ui.Say("Committing the container") 20 imageId, err := driver.Commit(containerId) 21 if err != nil { 22 state.Put("error", err) 23 ui.Error(err.Error()) 24 return multistep.ActionHalt 25 } 26 27 // Save the container ID 28 s.imageId = imageId 29 state.Put("image_id", s.imageId) 30 ui.Message(fmt.Sprintf("Image ID: %s", s.imageId)) 31 32 return multistep.ActionContinue 33 } 34 35 func (s *StepCommit) Cleanup(state multistep.StateBag) {}