{"modulePath":"github.com/hyperhq/libcompose","version":"v0.2.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package docker\n\n## Constants\n\n```go\nconst (\n\tNUMBER  = Label(\"com.docker.compose.container-number\")\n\tONEOFF  = Label(\"com.docker.compose.oneoff\")\n\tPROJECT = Label(\"com.docker.compose.project\")\n\tSERVICE = Label(\"com.docker.compose.service\")\n\tHASH    = Label(\"com.docker.compose.config-hash\")\n\tVERSION = Label(\"com.docker.compose.version\")\n)\n```\nLibcompose default labels.\n\n```go\nconst ComposeVersion = \"1.5.0\"\n```\nComposeVersion is name of docker-compose.yml file syntax supported version\n\n```go\nconst (\n\t// DefaultAPIVersion is the default docker API version set by libcompose\n\tDefaultAPIVersion = \"v1.20\"\n)\n```\n\n```go\nconst DefaultDockerfileName = \"Dockerfile\"\n```\nDefaultDockerfileName is the default name of a Dockerfile\n\n```go\nconst DefaultTag = \"latest\"\n```\nDefaultTag is the name of the default tag of an image.\n\n## Functions\n\n```go\nfunc And(left, right map[string][]string) map[string][]string\n```\nAnd returns a map of labels by merging the two specified values (left and right).\n\n```go\nfunc AndString(left, right string) string\n```\nAndString returns a json list of labels by merging the two specified values (left and right) serialized as string.\n\n```go\nfunc Convert(c *config.ServiceConfig, ctx project.Context) (*container.Config, *container.HostConfig, error)\n```\nConvert converts a service configuration to an docker API structures (Config and HostConfig)\n\n```go\nfunc CreateClient(c ClientOpts) (client.APIClient, error)\n```\nCreateClient creates a docker client based on the specified options.\n\n```go\nfunc CreateTar(p *project.Project, name string) (io.ReadCloser, error)\n```\nCreateTar create a build context tar for the specified project and service name.\n\n```go\nfunc Filter(vs []string, f func(string) bool) []string\n```\nFilter filters the specified string slice with the specified function.\n\n```go\nfunc GetContainerByID(client client.APIClient, id string) (*types.Container, error)\n```\nGetContainerByID looks up the hosts containers with the specified Id and returns it, or an error.\n\n```go\nfunc GetContainerByName(client client.APIClient, name string) (*types.Container, error)\n```\nGetContainerByName looks up the hosts containers with the specified name and returns it, or an error.\n\n```go\nfunc GetContainersByFilter(client client.APIClient, containerFilters ...map[string][]string) ([]types.Container, error)\n```\nGetContainersByFilter looks up the hosts containers with the specified filters and returns a list of container matching it, or an error.\n\n```go\nfunc NewProject(context *Context) (*project.Project, error)\n```\nNewProject creates a Project with the specified context.\n\n## Types\n\n```go\ntype Builder interface {\n\tBuild(imageName string, p *project.Project, service project.Service) error\n}\n```\nBuilder defines methods to provide a docker builder. This makes libcompose not tied up to the docker daemon builder.\n\n```go\ntype ClientFactory interface {\n\t// Create constructs a Docker client for the given service. The passed in\n\t// config may be nil in which case a generic client for the project should\n\t// be returned.\n\tCreate(service project.Service) client.APIClient\n}\n```\nClientFactory is a factory to create docker clients.\n\n```go\nfunc NewDefaultClientFactory(opts ClientOpts) (ClientFactory, error)\n```\nNewDefaultClientFactory creates and returns the default client factory that uses github.com/docker/engine-api client.\n\n```go\ntype ClientOpts struct {\n\tTLS        bool\n\tTLSVerify  bool\n\tTLSOptions tlsconfig.Options\n\tTrustKey   string\n\tHost       string\n\tAPIVersion string\n}\n```\nClientOpts holds docker client options (host, tls, ..)\n\n```go\ntype ConfigWrapper struct {\n\tConfig           *container.Config\n\tHostConfig       *container.HostConfig\n\tNetworkingConfig *network.NetworkingConfig\n}\n```\nConfigWrapper wraps Config, HostConfig and NetworkingConfig for a container.\n\n```go\nfunc ConvertToAPI(s *Service) (*ConfigWrapper, error)\n```\nConvertToAPI converts a service configuration to a docker API container configuration.\n\n```go\ntype Container struct {\n\tproject.EmptyService\n\t// contains filtered or unexported fields\n}\n```\nContainer holds information about a docker container and the service it is tied on. It implements Service interface by encapsulating a EmptyService.\n\n```go\nfunc NewContainer(client client.APIClient, name string, service *Service) *Container\n```\nNewContainer creates a container struct with the specified docker client, name and service.\n\n```go\nfunc (c *Container) Create(imageName string) (*types.Container, error)\n```\nCreate creates the container based on the specified image name and send an event to notify the container has been created. If the container already exists, does nothing.\n\n```go\nfunc (c *Container) CreateWithOverride(imageName string, configOverride *config.ServiceConfig) (*types.Container, error)\n```\nCreateWithOverride create container and override parts of the config to allow special situations to override the config generated from the compose file\n\n```go\nfunc (c *Container) Delete() error\n```\nDelete removes the container if existing. If the container is running, it tries to stop it first.\n\n```go\nfunc (c *Container) Down() error\n```\nDown stops and remove the container.\n\n```go\nfunc (c *Container) ID() (string, error)\n```\nID returns the container Id.\n\n```go\nfunc (c *Container) Info(qFlag bool) (project.Info, error)\n```\nInfo returns info about the container, like name, command, state or ports.\n\n```go\nfunc (c *Container) IsRunning() (bool, error)\n```\nIsRunning returns the running state of the container.\n\n```go\nfunc (c *Container) Kill() error\n```\nKill kill the container.\n\n```go\nfunc (c *Container) Log() error\n```\nLog forwards container logs to the project configured logger.\n\n```go\nfunc (c *Container) Name() string\n```\nName returns the container name.\n\n```go\nfunc (c *Container) OutOfSync(imageName string) (bool, error)\n```\nOutOfSync checks if the container is out of sync with the service definition. It looks if the the service hash container label is the same as the computed one.\n\n```go\nfunc (c *Container) Pause() error\n```\nPause pauses the container. If the containers are already paused, don't fail.\n\n```go\nfunc (c *Container) Port(port string) (string, error)\n```\nPort returns the host port the specified port is mapped on.\n\n```go\nfunc (c *Container) Pull() error\n```\nPull pulls the image the container is based on.\n\n```go\nfunc (c *Container) Recreate(imageName string) (*types.Container, error)\n```\nRecreate will not refresh the container by means of relaxation and enjoyment, just delete it and create a new one with the current configuration\n\n```go\nfunc (c *Container) Restart() error\n```\nRestart restarts the container if existing, does nothing otherwise.\n\n```go\nfunc (c *Container) Run(imageName string, configOverride *config.ServiceConfig) (int, error)\n```\nRun creates, start and attach to the container based on the image name, the specified configuration. It will always create a new container.\n\n```go\nfunc (c *Container) Start(container *types.Container) error\n```\nStart the specified container with the specified host config\n\n```go\nfunc (c *Container) Stop() error\n```\nStop stops the container.\n\n```go\nfunc (c *Container) Unpause() error\n```\nUnpause unpauses the container. If the containers are not paused, don't fail.\n\n```go\nfunc (c *Container) Up(imageName string) error\n```\nUp creates and start the container based on the image name and send an event to notify the container has been created. If the container exists but is stopped it tries to start it.\n\n```go\ntype Context struct {\n\tproject.Context\n\tBuilder       Builder\n\tClientFactory ClientFactory\n\tConfigDir     string\n\tConfigFile    *cliconfig.ConfigFile\n}\n```\nContext holds context meta information about a libcompose project and docker client information (like configuration file, builder to use, …)\n\n```go\nfunc (c *Context) LookupConfig() error\n```\nLookupConfig tries to load the docker configuration files, if any.\n\n```go\ntype DaemonBuilder struct {\n\t// contains filtered or unexported fields\n}\n```\nDaemonBuilder is the daemon \"docker build\" Builder implementation.\n\n```go\nfunc NewDaemonBuilder(ctx *Context) *DaemonBuilder\n```\nNewDaemonBuilder creates a DaemonBuilder based on the specified context.\n\n```go\nfunc (d *DaemonBuilder) Build(imageName string, p *project.Project, service project.Service) error\n```\nBuild implements Builder. It consumes the docker build API endpoint and sends a tar of the specified service build context.\n\n```go\ntype Label string\n```\nLabel represents a docker label.\n\n```go\nfunc (f Label) Eq(value string) map[string][]string\n```\nEq returns a label map representation with the specified value.\n\n```go\nfunc (f Label) EqString(value string) string\n```\nEqString returns a label json string representation with the specified value.\n\n```go\nfunc (f Label) Str() string\n```\nStr returns the label name.\n\n```go\ntype Namer interface {\n\tio.Closer\n\tNext() string\n}\n```\nNamer defines method to provide container name.\n\n```go\nfunc NewNamer(client client.APIClient, project, service string) Namer\n```\nNewNamer returns a namer that returns names based on the specified project and service name and an inner counter, e.g. project\\_service\\_1, project\\_service\\_2…\n\n```go\nfunc NewSingleNamer(name string) Namer\n```\nNewSingleNamer returns a namer that only allows a single name.\n\n```go\ntype Service struct {\n\t// contains filtered or unexported fields\n}\n```\nService is a project.Service implementations.\n\n```go\nfunc NewService(name string, serviceConfig *config.ServiceConfig, context *Context) *Service\n```\nNewService creates a service\n\n```go\nfunc (s *Service) Build() error\n```\nBuild implements Service.Build. If an imageName is specified or if the context has no build to work with it will do nothing. Otherwise it will try to build the image and returns an error if any.\n\n```go\nfunc (s *Service) Config() *config.ServiceConfig\n```\nConfig returns the configuration of the service (config.ServiceConfig).\n\n```go\nfunc (s *Service) Containers() ([]project.Container, error)\n```\nContainers implements Service.Containers. It returns the list of containers that are related to the service.\n\n```go\nfunc (s *Service) Create() error\n```\nCreate implements Service.Create. It ensures the image exists or build it if it can and then create a container.\n\n```go\nfunc (s *Service) Delete() error\n```\nDelete implements Service.Delete. It removes any containers related to the service.\n\n```go\nfunc (s *Service) DependentServices() []project.ServiceRelationship\n```\nDependentServices returns the dependent services (as an array of ServiceRelationship) of the service.\n\n```go\nfunc (s *Service) Down() error\n```\nDown implements Service.Down. It stops any containers related to the service and removes them.\n\n```go\nfunc (s *Service) Info(qFlag bool) (project.InfoSet, error)\n```\nInfo implements Service.Info. It returns an project.InfoSet with the containers related to this service (can be multiple if using the scale command).\n\n```go\nfunc (s *Service) Kill() error\n```\nKill implements Service.Kill. It kills any containers related to the service.\n\n```go\nfunc (s *Service) Log() error\n```\nLog implements Service.Log. It returns the docker logs for each container related to the service.\n\n```go\nfunc (s *Service) Name() string\n```\nName returns the service name.\n\n```go\nfunc (s *Service) Pause() error\n```\nPause implements Service.Pause. It puts into pause the container(s) related to the service.\n\n```go\nfunc (s *Service) Pull() error\n```\nPull implements Service.Pull. It pulls the image of the service and skip the service that would need to be built.\n\n```go\nfunc (s *Service) Restart() error\n```\nRestart implements Service.Restart. It restarts any containers related to the service.\n\n```go\nfunc (s *Service) Run(commandParts []string) (int, error)\n```\nRun implements Service.Run. It runs a one of command within the service container.\n\n```go\nfunc (s *Service) Scale(scale int) error\n```\nScale implements Service.Scale. It creates or removes containers to have the specified number of related container to the service to run.\n\n```go\nfunc (s *Service) Start() error\n```\nStart implements Service.Start. It tries to start a container without creating it.\n\n```go\nfunc (s *Service) Stop() error\n```\nStop implements Service.Stop. It stops any containers related to the service.\n\n```go\nfunc (s *Service) Unpause() error\n```\nUnpause implements Service.Pause. It brings back from pause the container(s) related to the service.\n\n```go\nfunc (s *Service) Up() error\n```\nUp implements Service.Up. It builds the image if needed, creates a container and start it.\n\n```go\ntype ServiceFactory struct {\n\t// contains filtered or unexported fields\n}\n```\nServiceFactory is an implementation of project.ServiceFactory.\n\n```go\nfunc (s *ServiceFactory) Create(project *project.Project, name string, serviceConfig *config.ServiceConfig) (project.Service, error)\n```\nCreate creates a Service based on the specified project, name and service configuration.\n\n","path":"github.com/hyperhq/libcompose/docker","name":"docker","synopsis":"","isRedistributable":true}
