daemon/container_operations_windows.go
4f0d95fa
 package daemon // import "github.com/docker/docker/daemon"
b9e4b957
 
600f0ad2
 import (
bd4e8aa6
 	"fmt"
 	"io/ioutil"
 	"os"
 
600f0ad2
 	"github.com/docker/docker/container"
bd4e8aa6
 	"github.com/docker/docker/pkg/system"
600f0ad2
 	"github.com/docker/libnetwork"
bd4e8aa6
 	"github.com/pkg/errors"
1009e6a4
 	"github.com/sirupsen/logrus"
600f0ad2
 )
b9e4b957
 
6bb0d181
 func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
b9e4b957
 	return nil, nil
 }
 
e0d533b1
 func (daemon *Daemon) setupConfigDir(c *container.Container) (setupErr error) {
 	if len(c.ConfigReferences) == 0 {
 		return nil
 	}
 
c0217180
 	localPath := c.ConfigsDirPath()
e0d533b1
 	logrus.Debugf("configs: setting up config dir: %s", localPath)
 
 	// create local config root
ed10ac6e
 	if err := system.MkdirAllWithACL(localPath, 0, system.SddlAdministratorsLocalSystem); err != nil {
e0d533b1
 		return errors.Wrap(err, "error creating config dir")
 	}
 
 	defer func() {
 		if setupErr != nil {
 			if err := os.RemoveAll(localPath); err != nil {
 				logrus.Errorf("error cleaning up config dir: %s", err)
 			}
 		}
 	}()
 
 	if c.DependencyStore == nil {
 		return fmt.Errorf("config store is not initialized")
 	}
 
 	for _, configRef := range c.ConfigReferences {
 		// TODO (ehazlett): use type switch when more are supported
 		if configRef.File == nil {
6f1d7ddf
 			// Runtime configs are not mounted into the container, but they're
 			// a valid type of config so we should not error when we encounter
 			// one.
 			if configRef.Runtime == nil {
 				logrus.Error("config target type is not a file or runtime target")
 			}
 			// However, in any case, this isn't a file config, so we have no
 			// further work to do
e0d533b1
 			continue
 		}
 
c0217180
 		fPath := c.ConfigFilePath(*configRef)
e0d533b1
 		log := logrus.WithFields(logrus.Fields{"name": configRef.File.Name, "path": fPath})
 
 		log.Debug("injecting config")
79b940fe
 		config, err := c.DependencyStore.Configs().Get(configRef.ConfigID)
 		if err != nil {
 			return errors.Wrap(err, "unable to get config from config store")
e0d533b1
 		}
 		if err := ioutil.WriteFile(fPath, config.Spec.Data, configRef.File.Mode); err != nil {
 			return errors.Wrap(err, "error injecting config")
 		}
 	}
 
 	return nil
 }
 
6bb0d181
 func (daemon *Daemon) setupIpcDirs(container *container.Container) error {
c8291f71
 	return nil
 }
 
331c8a86
 // TODO Windows: Fix Post-TP5. This is a hack to allow docker cp to work
6bb0d181
 // against containers which have volumes. You will still be able to cp
 // to somewhere on the container drive, but not to any mounted volumes
 // inside the container. Without this fix, docker cp is broken to any
 // container which has a volume, regardless of where the file is inside the
 // container.
 func (daemon *Daemon) mountVolumes(container *container.Container) error {
c8291f71
 	return nil
 }
7d8b5fc3
 
bd4e8aa6
 func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
 	if len(c.SecretReferences) == 0 {
 		return nil
 	}
 
eaa51928
 	localMountPath, err := c.SecretMountPath()
 	if err != nil {
 		return err
 	}
bd4e8aa6
 	logrus.Debugf("secrets: setting up secret dir: %s", localMountPath)
 
 	// create local secret root
ed10ac6e
 	if err := system.MkdirAllWithACL(localMountPath, 0, system.SddlAdministratorsLocalSystem); err != nil {
bd4e8aa6
 		return errors.Wrap(err, "error creating secret local directory")
 	}
 
 	defer func() {
 		if setupErr != nil {
 			if err := os.RemoveAll(localMountPath); err != nil {
 				logrus.Errorf("error cleaning up secret mount: %s", err)
 			}
 		}
 	}()
 
 	if c.DependencyStore == nil {
 		return fmt.Errorf("secret store is not initialized")
 	}
 
 	for _, s := range c.SecretReferences {
 		// TODO (ehazlett): use type switch when more are supported
 		if s.File == nil {
 			logrus.Error("secret target type is not a file target")
 			continue
 		}
 
 		// secrets are created in the SecretMountPath on the host, at a
 		// single level
eaa51928
 		fPath, err := c.SecretFilePath(*s)
 		if err != nil {
 			return err
 		}
bd4e8aa6
 		logrus.WithFields(logrus.Fields{
 			"name": s.File.Name,
 			"path": fPath,
 		}).Debug("injecting secret")
79b940fe
 		secret, err := c.DependencyStore.Secrets().Get(s.SecretID)
 		if err != nil {
 			return errors.Wrap(err, "unable to get secret from secret store")
bd4e8aa6
 		}
 		if err := ioutil.WriteFile(fPath, secret.Spec.Data, s.File.Mode); err != nil {
 			return errors.Wrap(err, "error injecting secret")
 		}
 	}
 
 	return nil
 }
 
6bb0d181
 func killProcessDirectly(container *container.Container) error {
3a852d84
 	return nil
 }
e8026d8a
 
 func isLinkable(child *container.Container) bool {
 	return false
 }
1991f6eb
 
 func enableIPOnPredefinedNetwork() bool {
 	return true
 }
50f02b58
 
20dde018
 // serviceDiscoveryOnDefaultNetwork indicates if service discovery is supported on the default network
 func serviceDiscoveryOnDefaultNetwork() bool {
 	return true
 }
 
e353e7e3
 func (daemon *Daemon) setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]libnetwork.SandboxOption) error {
600f0ad2
 	return nil
 }
 
349913ce
 func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
 
 	if nc.HostConfig.Isolation.IsHyperV() {
 		return fmt.Errorf("sharing of hyperv containers network is not supported")
 	}
 
040afcce
 	container.NetworkSharedContainerID = nc.ID
349913ce
 
 	if nc.NetworkSettings != nil {
 		for n := range nc.NetworkSettings.Networks {
ccc2ed01
 			sn, err := daemon.FindNetwork(n)
349913ce
 			if err != nil {
 				continue
 			}
 
cc8f358c
 			ep, err := getEndpointInNetwork(nc.Name, sn)
349913ce
 			if err != nil {
 				continue
 			}
 
 			data, err := ep.DriverInfo()
 			if err != nil {
 				continue
 			}
 
 			if data["GW_INFO"] != nil {
 				gwInfo := data["GW_INFO"].(map[string]interface{})
 				if gwInfo["hnsid"] != nil {
 					container.SharedEndpointList = append(container.SharedEndpointList, gwInfo["hnsid"].(string))
 				}
 			}
 
 			if data["hnsid"] != nil {
 				container.SharedEndpointList = append(container.SharedEndpointList, data["hnsid"].(string))
 			}
 		}
 	}
 
 	return nil
600f0ad2
 }