docker

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2016 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const ComposeVersion = "1.5.0"

ComposeVersion is name of docker-compose.yml file syntax supported version

Variables

This section is empty.

Functions

func Convert

Convert converts a service configuration to an docker API structures (Config and HostConfig)

func DefaultDependentServices added in v0.3.0

func DefaultDependentServices(p *project.Project, s project.Service) []project.ServiceRelationship

DefaultDependentServices return the dependent services (as an array of ServiceRelationship) for the specified project and service. It looks for : links, volumesFrom, net and ipc configuration. It uses default project implementation and append some docker specific ones.

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter filters the specified string slice with the specified function.

func GetContainer added in v0.3.0

func GetContainer(ctx context.Context, clientInstance client.APIClient, id string) (*types.ContainerJSON, error)

GetContainer looks up the hosts containers with the specified ID or name and returns it, or an error.

func GetContainerFromIpcLikeConfig added in v0.3.0

func GetContainerFromIpcLikeConfig(p *project.Project, conf string) string

GetContainerFromIpcLikeConfig returns name of the service that shares the IPC namespace with the specified service.

func GetContainersByFilter

func GetContainersByFilter(ctx context.Context, clientInstance client.APIClient, containerFilters ...map[string][]string) ([]types.Container, error)

GetContainersByFilter looks up the hosts containers with the specified filters and returns a list of container matching it, or an error.

func NewProject

func NewProject(context *Context, parseOptions *config.ParseOptions) (project.APIProject, error)

NewProject creates a Project with the specified context.

Types

type AuthLookup added in v0.3.0

type AuthLookup interface {
	All() map[string]types.AuthConfig
	Lookup(repoInfo *registry.RepositoryInfo) types.AuthConfig
}

AuthLookup defines a method for looking up authentication information

type ConfigAuthLookup added in v0.3.0

type ConfigAuthLookup struct {
	// contains filtered or unexported fields
}

ConfigAuthLookup implements AuthLookup by reading a Docker config file

func NewConfigAuthLookup added in v0.3.0

func NewConfigAuthLookup(context *Context) *ConfigAuthLookup

NewConfigAuthLookup creates a new ConfigAuthLookup for a given context

func (*ConfigAuthLookup) All added in v0.3.0

func (c *ConfigAuthLookup) All() map[string]types.AuthConfig

All uses a Docker config file to get all authentication information

func (*ConfigAuthLookup) Lookup added in v0.3.0

Lookup uses a Docker config file to lookup authentication information

type ConfigWrapper added in v0.2.0

type ConfigWrapper struct {
	Config           *container.Config
	HostConfig       *container.HostConfig
	NetworkingConfig *network.NetworkingConfig
}

ConfigWrapper wraps Config, HostConfig and NetworkingConfig for a container.

func ConvertToAPI

func ConvertToAPI(serviceConfig *config.ServiceConfig, ctx project.Context, clientFactory composeclient.Factory) (*ConfigWrapper, error)

ConvertToAPI converts a service configuration to a docker API container configuration.

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container holds information about a docker container and the service it is tied on.

func CreateContainer added in v0.3.0

func CreateContainer(ctx context.Context, client client.APIClient, name string, configWrapper *ConfigWrapper) (*Container, error)

CreateContainer creates a container and return a Container struct (and an error if any)

func New added in v0.3.0

func New(ctx context.Context, client client.APIClient, id string) (*Container, error)

New creates a container struct with the specified client, id and name

func NewInspected added in v0.3.0

func NewInspected(client client.APIClient, container *types.ContainerJSON) *Container

NewInspected creates a container struct from an inspected container

func (*Container) Hash added in v0.3.0

func (c *Container) Hash() string

Hash returns the container hash stored as label.

func (*Container) ID

func (c *Container) ID() (string, error)

ID returns the container Id.

func (*Container) Image added in v0.3.0

func (c *Container) Image() string

Image returns the container image. Depending on the engine version its either the complete id or the digest reference the image.

func (*Container) ImageConfig added in v0.3.0

func (c *Container) ImageConfig() string

ImageConfig returns the container image stored in the config. It's the human-readable name of the image.

func (*Container) Info

func (c *Container) Info(ctx context.Context, qFlag bool) (project.Info, error)

Info returns info about the container, like name, command, state or ports.

func (*Container) IsRunning

func (c *Container) IsRunning(ctx context.Context) (bool, error)

IsRunning returns the running state of the container. FIXME(vdemeester): remove the nil error here

func (*Container) Kill

func (c *Container) Kill(ctx context.Context, signal string) error

Kill kill the container.

func (*Container) Log

func (c *Container) Log(ctx context.Context, l logger.Logger, follow bool) error

Log forwards container logs to the project configured logger.

func (*Container) Name

func (c *Container) Name() string

Name returns the container name.

func (*Container) Networks added in v0.3.0

func (c *Container) Networks() (map[string]*network.EndpointSettings, error)

Networks returns the containers network

func (*Container) Number added in v0.3.0

func (c *Container) Number() (int, error)

Number returns the container number stored as label.

func (*Container) Pause

func (c *Container) Pause(ctx context.Context) error

Pause pauses the container. If the containers are already paused, don't fail.

func (*Container) Port

func (c *Container) Port(ctx context.Context, port string) (string, error)

Port returns the host port the specified port is mapped on.

func (*Container) Remove added in v0.3.0

func (c *Container) Remove(ctx context.Context, removeVolume bool) error

Remove removes the container.

func (*Container) Rename added in v0.3.0

func (c *Container) Rename(ctx context.Context, newName string) error

Rename rename the container.

func (*Container) Restart

func (c *Container) Restart(ctx context.Context, timeout int) error

Restart restarts the container if existing, does nothing otherwise.

func (*Container) Run added in v0.2.0

func (c *Container) Run(ctx context.Context, configOverride *config.ServiceConfig) (int, error)

Run creates, start and attach to the container based on the image name, the specified configuration. It will always create a new container.

func (*Container) Start added in v0.2.0

func (c *Container) Start(ctx context.Context) error

Start the specified container with the specified host config

func (*Container) Stop added in v0.2.0

func (c *Container) Stop(ctx context.Context, timeout int) error

Stop stops the container.

func (*Container) Unpause

func (c *Container) Unpause(ctx context.Context) error

Unpause unpauses the container. If the containers are not paused, don't fail.

type Context

type Context struct {
	project.Context
	ClientFactory client.Factory
	ConfigDir     string
	ConfigFile    *configfile.ConfigFile
	AuthLookup    AuthLookup
}

Context holds context meta information about a libcompose project and docker client information (like configuration file, builder to use, …)

func (*Context) LookupConfig

func (c *Context) LookupConfig() error

LookupConfig tries to load the docker configuration files, if any.

type Namer

type Namer interface {
	Next() (string, int)
}

Namer defines method to provide container name.

func NewNamer

func NewNamer(ctx context.Context, client client.ContainerAPIClient, project, service string, oneOff bool) (Namer, error)

NewNamer 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…

func NewSingleNamer

func NewSingleNamer(name string) Namer

NewSingleNamer returns a namer that only allows a single name.

type Project added in v0.3.0

type Project struct {
	// contains filtered or unexported fields
}

Project implements project.RuntimeProject and define docker runtime specific methods.

func (*Project) RemoveOrphans added in v0.3.0

func (p *Project) RemoveOrphans(ctx context.Context, projectName string, serviceConfigs *config.ServiceConfigs) error

RemoveOrphans implements project.RuntimeProject.RemoveOrphans. It will remove orphan containers that are part of the project but not to any services.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a project.Service implementations.

func NewService

func NewService(name string, serviceConfig *config.ServiceConfig, context *Context) *Service

NewService creates a service

func (*Service) Build

func (s *Service) Build(ctx context.Context, buildOptions options.Build) error

Build implements Service.Build. It will try to build the image and returns an error if any.

func (*Service) Config

func (s *Service) Config() *config.ServiceConfig

Config returns the configuration of the service (config.ServiceConfig).

func (*Service) Containers

func (s *Service) Containers(ctx context.Context) ([]project.Container, error)

Containers implements Service.Containers. It returns the list of containers that are related to the service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, options options.Create) error

Create implements Service.Create. It ensures the image exists or build it if it can and then create a container.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, options options.Delete) error

Delete implements Service.Delete. It removes any containers related to the service.

func (*Service) DependentServices

func (s *Service) DependentServices() []project.ServiceRelationship

DependentServices returns the dependent services (as an array of ServiceRelationship) of the service.

func (*Service) Events added in v0.3.0

func (s *Service) Events(ctx context.Context, evts chan events.ContainerEvent) error

Events implements Service.Events. It listen to all real-time events happening for the service, and put them into the specified chan.

func (*Service) ImageExists added in v0.3.0

func (s *Service) ImageExists(ctx context.Context) (bool, error)

ImageExists returns whether or not the service image already exists

func (*Service) Info

func (s *Service) Info(ctx context.Context, qFlag bool) (project.InfoSet, error)

Info implements Service.Info. It returns an project.InfoSet with the containers related to this service (can be multiple if using the scale command).

func (*Service) Kill

func (s *Service) Kill(ctx context.Context, signal string) error

Kill implements Service.Kill. It kills any containers related to the service.

func (*Service) Log

func (s *Service) Log(ctx context.Context, follow bool) error

Log implements Service.Log. It returns the docker logs for each container related to the service.

func (*Service) Name

func (s *Service) Name() string

Name returns the service name.

func (*Service) NetworkConnect added in v0.3.0

func (s *Service) NetworkConnect(ctx context.Context, c *Container, net *yaml.Network, oneOff bool) error

NetworkConnect connects the container to the specified network FIXME(vdemeester) will be refactor with Container refactoring

func (*Service) NetworkDisconnect added in v0.3.0

func (s *Service) NetworkDisconnect(ctx context.Context, c *Container, net *yaml.Network, oneOff bool) error

NetworkDisconnect disconnects the container from the specified network

func (*Service) OutOfSync added in v0.3.0

func (s *Service) OutOfSync(ctx context.Context, c *Container) (bool, error)

OutOfSync 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.

func (*Service) Pause

func (s *Service) Pause(ctx context.Context) error

Pause implements Service.Pause. It puts into pause the container(s) related to the service.

func (*Service) Pull

func (s *Service) Pull(ctx context.Context) error

Pull implements Service.Pull. It pulls the image of the service and skip the service that would need to be built.

func (*Service) RemoveImage added in v0.3.0

func (s *Service) RemoveImage(ctx context.Context, imageType options.ImageType) error

RemoveImage implements Service.RemoveImage. It removes images used for the service depending on the specified type.

func (*Service) Restart

func (s *Service) Restart(ctx context.Context, timeout int) error

Restart implements Service.Restart. It restarts any containers related to the service.

func (*Service) Run added in v0.2.0

func (s *Service) Run(ctx context.Context, commandParts []string, options options.Run) (int, error)

Run implements Service.Run. It runs a one of command within the service container. It always create a new container.

func (*Service) Scale

func (s *Service) Scale(ctx context.Context, scale int, timeout int) error

Scale implements Service.Scale. It creates or removes containers to have the specified number of related container to the service to run.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start implements Service.Start. It tries to start a container without creating it.

func (*Service) Stop added in v0.2.0

func (s *Service) Stop(ctx context.Context, timeout int) error

Stop implements Service.Stop. It stops any containers related to the service.

func (*Service) Unpause

func (s *Service) Unpause(ctx context.Context) error

Unpause implements Service.Pause. It brings back from pause the container(s) related to the service.

func (*Service) Up

func (s *Service) Up(ctx context.Context, options options.Up) error

Up implements Service.Up. It builds the image if needed, creates a container and start it.

type ServiceFactory

type ServiceFactory struct {
	// contains filtered or unexported fields
}

ServiceFactory is an implementation of project.ServiceFactory.

func (*ServiceFactory) Create

func (s *ServiceFactory) Create(project *project.Project, name string, serviceConfig *config.ServiceConfig) (project.Service, error)

Create creates a Service based on the specified project, name and service configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL