2013-11-09 12:12:23 -08:00
|
|
|
package docker
|
|
|
|
|
2013-11-09 13:15:51 -08:00
|
|
|
import (
|
|
|
|
"io"
|
2015-05-29 09:29:59 -07:00
|
|
|
|
|
|
|
"github.com/hashicorp/go-version"
|
2013-11-09 13:15:51 -08:00
|
|
|
)
|
|
|
|
|
2013-11-09 12:12:23 -08:00
|
|
|
// Driver is the interface that has to be implemented to communicate with
|
|
|
|
// Docker. The Driver interface also allows the steps to be tested since
|
|
|
|
// a mock driver can be shimmed in.
|
|
|
|
type Driver interface {
|
2014-07-20 19:57:10 +01:00
|
|
|
// Commit the container to a tag
|
2016-11-24 13:33:42 +01:00
|
|
|
Commit(id string, author string, changes []string, message string) (string, error)
|
2014-07-20 19:57:10 +01:00
|
|
|
|
2014-01-19 19:48:06 -08:00
|
|
|
// Delete an image that is imported into Docker
|
|
|
|
DeleteImage(id string) error
|
|
|
|
|
2013-11-09 13:15:51 -08:00
|
|
|
// Export exports the container with the given ID to the given writer.
|
|
|
|
Export(id string, dst io.Writer) error
|
|
|
|
|
2014-01-19 19:55:01 -08:00
|
|
|
// Import imports a container from a tar file
|
2018-12-17 22:13:40 -06:00
|
|
|
Import(path string, changes []string, repo string) (string, error)
|
2014-01-19 19:55:01 -08:00
|
|
|
|
2015-06-14 22:09:38 -07:00
|
|
|
// IPAddress returns the address of the container that can be used
|
|
|
|
// for external access.
|
|
|
|
IPAddress(id string) (string, error)
|
|
|
|
|
2020-09-16 10:08:44 +02:00
|
|
|
// Sha256 returns the sha256 id of the image
|
|
|
|
Sha256(id string) (string, error)
|
|
|
|
|
2014-09-05 15:06:07 -07:00
|
|
|
// Login. This will lock the driver from performing another Login
|
|
|
|
// until Logout is called. Therefore, any users MUST call Logout.
|
2017-10-25 09:53:51 -07:00
|
|
|
Login(repo, username, password string) error
|
2014-09-05 14:26:19 -07:00
|
|
|
|
2014-09-05 15:06:07 -07:00
|
|
|
// Logout. This can only be called if Login succeeded.
|
2014-09-05 14:26:19 -07:00
|
|
|
Logout(repo string) error
|
|
|
|
|
2013-11-09 12:12:23 -08:00
|
|
|
// Pull should pull down the given image.
|
|
|
|
Pull(image string) error
|
2013-11-09 13:03:01 -08:00
|
|
|
|
2014-01-19 20:42:42 -08:00
|
|
|
// Push pushes an image to a Docker index/registry.
|
|
|
|
Push(name string) error
|
|
|
|
|
2014-07-20 21:58:07 +01:00
|
|
|
// Save an image with the given ID to the given writer.
|
|
|
|
SaveImage(id string, dst io.Writer) error
|
|
|
|
|
2013-11-09 13:03:01 -08:00
|
|
|
// StartContainer starts a container and returns the ID for that container,
|
|
|
|
// along with a potential error.
|
|
|
|
StartContainer(*ContainerConfig) (string, error)
|
|
|
|
|
2019-03-27 14:51:50 -07:00
|
|
|
// KillContainer forcibly stops a container.
|
|
|
|
KillContainer(id string) error
|
|
|
|
|
|
|
|
// StopContainer gently stops a container.
|
2013-11-09 13:03:01 -08:00
|
|
|
StopContainer(id string) error
|
2013-11-09 21:26:05 -08:00
|
|
|
|
2014-07-20 19:58:03 +01:00
|
|
|
// TagImage tags the image with the given ID
|
2015-04-18 13:12:28 +09:00
|
|
|
TagImage(id string, repo string, force bool) error
|
2014-07-20 19:58:03 +01:00
|
|
|
|
2013-11-09 21:26:05 -08:00
|
|
|
// Verify verifies that the driver can run
|
|
|
|
Verify() error
|
2015-05-29 09:29:59 -07:00
|
|
|
|
|
|
|
// Version reads the Docker version
|
|
|
|
Version() (*version.Version, error)
|
2013-11-09 13:03:01 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerConfig is the configuration used to start a container.
|
|
|
|
type ContainerConfig struct {
|
2013-12-27 10:17:45 -07:00
|
|
|
Image string
|
|
|
|
RunCommand []string
|
2020-07-11 18:23:55 +02:00
|
|
|
Device []string
|
2020-07-11 17:02:31 +02:00
|
|
|
CapAdd []string
|
|
|
|
CapDrop []string
|
2013-12-27 10:17:45 -07:00
|
|
|
Volumes map[string]string
|
2020-07-11 17:02:31 +02:00
|
|
|
TmpFs []string
|
2016-04-29 22:12:20 -04:00
|
|
|
Privileged bool
|
2013-12-27 10:17:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is the template that is used for the RunCommand in the ContainerConfig.
|
|
|
|
type startContainerTemplate struct {
|
2014-09-08 10:28:21 -07:00
|
|
|
Image string
|
2013-11-09 12:12:23 -08:00
|
|
|
}
|