container_operations_windows.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. package daemon
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "os"
  6. "github.com/Sirupsen/logrus"
  7. "github.com/docker/docker/container"
  8. "github.com/docker/docker/pkg/system"
  9. "github.com/docker/libnetwork"
  10. "github.com/pkg/errors"
  11. )
  12. func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
  13. return nil, nil
  14. }
  15. func (daemon *Daemon) setupConfigDir(c *container.Container) (setupErr error) {
  16. if len(c.ConfigReferences) == 0 {
  17. return nil
  18. }
  19. localPath := c.ConfigsDirPath()
  20. logrus.Debugf("configs: setting up config dir: %s", localPath)
  21. // create local config root
  22. if err := system.MkdirAllWithACL(localPath, 0); err != nil {
  23. return errors.Wrap(err, "error creating config dir")
  24. }
  25. defer func() {
  26. if setupErr != nil {
  27. if err := os.RemoveAll(localPath); err != nil {
  28. logrus.Errorf("error cleaning up config dir: %s", err)
  29. }
  30. }
  31. }()
  32. if c.DependencyStore == nil {
  33. return fmt.Errorf("config store is not initialized")
  34. }
  35. for _, configRef := range c.ConfigReferences {
  36. // TODO (ehazlett): use type switch when more are supported
  37. if configRef.File == nil {
  38. logrus.Error("config target type is not a file target")
  39. continue
  40. }
  41. fPath := c.ConfigFilePath(*configRef)
  42. log := logrus.WithFields(logrus.Fields{"name": configRef.File.Name, "path": fPath})
  43. log.Debug("injecting config")
  44. config := c.DependencyStore.Configs().Get(configRef.ConfigID)
  45. if config == nil {
  46. return fmt.Errorf("unable to get config from config store")
  47. }
  48. if err := ioutil.WriteFile(fPath, config.Spec.Data, configRef.File.Mode); err != nil {
  49. return errors.Wrap(err, "error injecting config")
  50. }
  51. }
  52. return nil
  53. }
  54. // getSize returns real size & virtual size
  55. func (daemon *Daemon) getSize(containerID string) (int64, int64) {
  56. // TODO Windows
  57. return 0, 0
  58. }
  59. func (daemon *Daemon) setupIpcDirs(container *container.Container) error {
  60. return nil
  61. }
  62. // TODO Windows: Fix Post-TP5. This is a hack to allow docker cp to work
  63. // against containers which have volumes. You will still be able to cp
  64. // to somewhere on the container drive, but not to any mounted volumes
  65. // inside the container. Without this fix, docker cp is broken to any
  66. // container which has a volume, regardless of where the file is inside the
  67. // container.
  68. func (daemon *Daemon) mountVolumes(container *container.Container) error {
  69. return nil
  70. }
  71. func detachMounted(path string) error {
  72. return nil
  73. }
  74. func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
  75. if len(c.SecretReferences) == 0 {
  76. return nil
  77. }
  78. localMountPath := c.SecretMountPath()
  79. logrus.Debugf("secrets: setting up secret dir: %s", localMountPath)
  80. // create local secret root
  81. if err := system.MkdirAllWithACL(localMountPath, 0); err != nil {
  82. return errors.Wrap(err, "error creating secret local directory")
  83. }
  84. defer func() {
  85. if setupErr != nil {
  86. if err := os.RemoveAll(localMountPath); err != nil {
  87. logrus.Errorf("error cleaning up secret mount: %s", err)
  88. }
  89. }
  90. }()
  91. if c.DependencyStore == nil {
  92. return fmt.Errorf("secret store is not initialized")
  93. }
  94. for _, s := range c.SecretReferences {
  95. // TODO (ehazlett): use type switch when more are supported
  96. if s.File == nil {
  97. logrus.Error("secret target type is not a file target")
  98. continue
  99. }
  100. // secrets are created in the SecretMountPath on the host, at a
  101. // single level
  102. fPath := c.SecretFilePath(*s)
  103. logrus.WithFields(logrus.Fields{
  104. "name": s.File.Name,
  105. "path": fPath,
  106. }).Debug("injecting secret")
  107. secret := c.DependencyStore.Secrets().Get(s.SecretID)
  108. if secret == nil {
  109. return fmt.Errorf("unable to get secret from secret store")
  110. }
  111. if err := ioutil.WriteFile(fPath, secret.Spec.Data, s.File.Mode); err != nil {
  112. return errors.Wrap(err, "error injecting secret")
  113. }
  114. }
  115. return nil
  116. }
  117. func killProcessDirectly(container *container.Container) error {
  118. return nil
  119. }
  120. func isLinkable(child *container.Container) bool {
  121. return false
  122. }
  123. func enableIPOnPredefinedNetwork() bool {
  124. return true
  125. }
  126. func (daemon *Daemon) isNetworkHotPluggable() bool {
  127. return false
  128. }
  129. func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]libnetwork.SandboxOption) error {
  130. return nil
  131. }
  132. func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
  133. container.NetworkSharedContainerID = nc.ID
  134. }