github.com/sneal/packer@v0.5.2/builder/docker/driver.go (about) 1 package docker 2 3 import ( 4 "io" 5 ) 6 7 // Driver is the interface that has to be implemented to communicate with 8 // Docker. The Driver interface also allows the steps to be tested since 9 // a mock driver can be shimmed in. 10 type Driver interface { 11 // Delete an image that is imported into Docker 12 DeleteImage(id string) error 13 14 // Export exports the container with the given ID to the given writer. 15 Export(id string, dst io.Writer) error 16 17 // Import imports a container from a tar file 18 Import(path, repo string) (string, error) 19 20 // Pull should pull down the given image. 21 Pull(image string) error 22 23 // Push pushes an image to a Docker index/registry. 24 Push(name string) error 25 26 // StartContainer starts a container and returns the ID for that container, 27 // along with a potential error. 28 StartContainer(*ContainerConfig) (string, error) 29 30 // StopContainer forcibly stops a container. 31 StopContainer(id string) error 32 33 // Verify verifies that the driver can run 34 Verify() error 35 } 36 37 // ContainerConfig is the configuration used to start a container. 38 type ContainerConfig struct { 39 Image string 40 RunCommand []string 41 Volumes map[string]string 42 } 43 44 // This is the template that is used for the RunCommand in the ContainerConfig. 45 type startContainerTemplate struct { 46 Image string 47 Volumes string 48 }