github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/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 // Commit the container to a tag 12 Commit(id string) (string, error) 13 14 // Delete an image that is imported into Docker 15 DeleteImage(id string) error 16 17 // Export exports the container with the given ID to the given writer. 18 Export(id string, dst io.Writer) error 19 20 // Import imports a container from a tar file 21 Import(path, repo string) (string, error) 22 23 // Login. This will lock the driver from performing another Login 24 // until Logout is called. Therefore, any users MUST call Logout. 25 Login(repo, email, username, password string) error 26 27 // Logout. This can only be called if Login succeeded. 28 Logout(repo string) error 29 30 // Pull should pull down the given image. 31 Pull(image string) error 32 33 // Push pushes an image to a Docker index/registry. 34 Push(name string) error 35 36 // Save an image with the given ID to the given writer. 37 SaveImage(id string, dst io.Writer) error 38 39 // StartContainer starts a container and returns the ID for that container, 40 // along with a potential error. 41 StartContainer(*ContainerConfig) (string, error) 42 43 // StopContainer forcibly stops a container. 44 StopContainer(id string) error 45 46 // TagImage tags the image with the given ID 47 TagImage(id string, repo string) error 48 49 // Verify verifies that the driver can run 50 Verify() error 51 } 52 53 // ContainerConfig is the configuration used to start a container. 54 type ContainerConfig struct { 55 Image string 56 RunCommand []string 57 Volumes map[string]string 58 } 59 60 // This is the template that is used for the RunCommand in the ContainerConfig. 61 type startContainerTemplate struct { 62 Image string 63 }