本文整理汇总了Golang中github.com/fsouza/go-dockerclient.HostConfig.Binds方法的典型用法代码示例。如果您正苦于以下问题:Golang HostConfig.Binds方法的具体用法?Golang HostConfig.Binds怎么用?Golang HostConfig.Binds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/fsouza/go-dockerclient.HostConfig
的用法示例。
在下文中一共展示了HostConfig.Binds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addWeaveWaitVolume
func (proxy *Proxy) addWeaveWaitVolume(hostConfig *docker.HostConfig) {
var binds []string
for _, bind := range hostConfig.Binds {
s := strings.Split(bind, ":")
if len(s) >= 2 && s[1] == "/w" {
continue
}
binds = append(binds, bind)
}
hostConfig.Binds = append(binds, fmt.Sprintf("%s:/w:ro", proxy.weaveWaitVolume))
}
示例2: Build
// Build is a helper method to perform a Docker build against the
// provided Docker client. It will load the image if not specified,
// create a container if one does not already exist, and start a
// container if the Dockerfile contains RUN commands. It will cleanup
// any containers it creates directly, and set the e.Image.ID field
// to the generated image.
func (e *ClientExecutor) Build(r io.Reader, args map[string]string) error {
b := NewBuilder()
b.Args = args
if e.Excludes == nil {
excludes, err := ParseDockerignore(e.Directory)
if err != nil {
return err
}
e.Excludes = append(excludes, ".dockerignore")
}
// TODO: check the Docker daemon version (1.20 is required for Upload)
node, err := parser.Parse(r)
if err != nil {
return err
}
// identify the base image
from, err := b.From(node)
if err != nil {
return err
}
// load the image
if e.Image == nil {
if from == NoBaseImageSpecifier {
if runtime.GOOS == "windows" {
return fmt.Errorf("building from scratch images is not supported")
}
from, err = e.CreateScratchImage()
if err != nil {
return fmt.Errorf("unable to create a scratch image for this build: %v", err)
}
defer e.CleanupImage(from)
}
glog.V(4).Infof("Retrieving image %q", from)
e.Image, err = e.LoadImage(from)
if err != nil {
return err
}
}
// update the builder with any information from the image, including ONBUILD
// statements
if err := b.FromImage(e.Image, node); err != nil {
return err
}
b.RunConfig.Image = from
e.LogFn("FROM %s", from)
glog.V(4).Infof("step: FROM %s", from)
var sharedMount string
// create a container to execute in, if necessary
mustStart := b.RequiresStart(node)
if e.Container == nil {
opts := docker.CreateContainerOptions{
Config: &docker.Config{
Image: from,
},
}
if mustStart {
// Transient mounts only make sense on images that will be running processes
if len(e.TransientMounts) > 0 {
volumeName, err := randSeq(imageSafeCharacters, 24)
if err != nil {
return err
}
v, err := e.Client.CreateVolume(docker.CreateVolumeOptions{Name: volumeName})
if err != nil {
return fmt.Errorf("unable to create volume to mount secrets: %v", err)
}
defer e.cleanupVolume(volumeName)
sharedMount = v.Mountpoint
opts.HostConfig = &docker.HostConfig{
Binds: []string{sharedMount + ":/tmp/__temporarymount"},
}
}
// TODO: windows support
if len(e.Command) > 0 {
opts.Config.Cmd = e.Command
opts.Config.Entrypoint = nil
} else {
// TODO; replace me with a better default command
opts.Config.Cmd = []string{"sleep 86400"}
opts.Config.Entrypoint = []string{"/bin/sh", "-c"}
}
}
if len(opts.Config.Cmd) == 0 {
opts.Config.Entrypoint = []string{"/bin/sh", "-c", "# NOP"}
}
//.........这里部分代码省略.........