daemon_unix.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. // +build linux freebsd
  2. package daemon
  3. import (
  4. "fmt"
  5. "net"
  6. "net/http"
  7. "os"
  8. "path/filepath"
  9. "strings"
  10. "syscall"
  11. "github.com/Sirupsen/logrus"
  12. "github.com/docker/docker/autogen/dockerversion"
  13. "github.com/docker/docker/daemon/graphdriver"
  14. "github.com/docker/docker/pkg/fileutils"
  15. "github.com/docker/docker/pkg/parsers"
  16. "github.com/docker/docker/pkg/parsers/kernel"
  17. "github.com/docker/docker/pkg/sysinfo"
  18. "github.com/docker/docker/pkg/system"
  19. "github.com/docker/docker/runconfig"
  20. "github.com/docker/docker/utils"
  21. "github.com/docker/libnetwork"
  22. nwapi "github.com/docker/libnetwork/api"
  23. nwconfig "github.com/docker/libnetwork/config"
  24. "github.com/docker/libnetwork/netlabel"
  25. "github.com/docker/libnetwork/options"
  26. "github.com/opencontainers/runc/libcontainer/label"
  27. )
  28. const (
  29. // See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269
  30. linuxMinCPUShares = 2
  31. linuxMaxCPUShares = 262144
  32. platformSupported = true
  33. )
  34. func parseSecurityOpt(container *Container, config *runconfig.HostConfig) error {
  35. var (
  36. labelOpts []string
  37. err error
  38. )
  39. for _, opt := range config.SecurityOpt {
  40. con := strings.SplitN(opt, ":", 2)
  41. if len(con) == 1 {
  42. return fmt.Errorf("Invalid --security-opt: %q", opt)
  43. }
  44. switch con[0] {
  45. case "label":
  46. labelOpts = append(labelOpts, con[1])
  47. case "apparmor":
  48. container.AppArmorProfile = con[1]
  49. default:
  50. return fmt.Errorf("Invalid --security-opt: %q", opt)
  51. }
  52. }
  53. container.ProcessLabel, container.MountLabel, err = label.InitLabels(labelOpts)
  54. return err
  55. }
  56. func checkKernelVersion(k, major, minor int) bool {
  57. if v, err := kernel.GetKernelVersion(); err != nil {
  58. logrus.Warnf("%s", err)
  59. } else {
  60. if kernel.CompareKernelVersion(*v, kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) < 0 {
  61. return false
  62. }
  63. }
  64. return true
  65. }
  66. func checkKernel() error {
  67. // Check for unsupported kernel versions
  68. // FIXME: it would be cleaner to not test for specific versions, but rather
  69. // test for specific functionalities.
  70. // Unfortunately we can't test for the feature "does not cause a kernel panic"
  71. // without actually causing a kernel panic, so we need this workaround until
  72. // the circumstances of pre-3.10 crashes are clearer.
  73. // For details see https://github.com/docker/docker/issues/407
  74. if !checkKernelVersion(3, 10, 0) {
  75. v, _ := kernel.GetKernelVersion()
  76. if os.Getenv("DOCKER_NOWARN_KERNEL_VERSION") == "" {
  77. logrus.Warnf("Your Linux kernel version %s can be unstable running docker. Please upgrade your kernel to 3.10.0.", v.String())
  78. }
  79. }
  80. return nil
  81. }
  82. // adaptContainerSettings is called during container creation to modify any
  83. // settings necessary in the HostConfig structure.
  84. func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig, adjustCPUShares bool) {
  85. if hostConfig == nil {
  86. return
  87. }
  88. if adjustCPUShares && hostConfig.CPUShares > 0 {
  89. // Handle unsupported CPUShares
  90. if hostConfig.CPUShares < linuxMinCPUShares {
  91. logrus.Warnf("Changing requested CPUShares of %d to minimum allowed of %d", hostConfig.CPUShares, linuxMinCPUShares)
  92. hostConfig.CPUShares = linuxMinCPUShares
  93. } else if hostConfig.CPUShares > linuxMaxCPUShares {
  94. logrus.Warnf("Changing requested CPUShares of %d to maximum allowed of %d", hostConfig.CPUShares, linuxMaxCPUShares)
  95. hostConfig.CPUShares = linuxMaxCPUShares
  96. }
  97. }
  98. if hostConfig.Memory > 0 && hostConfig.MemorySwap == 0 {
  99. // By default, MemorySwap is set to twice the size of Memory.
  100. hostConfig.MemorySwap = hostConfig.Memory * 2
  101. }
  102. }
  103. // verifyPlatformContainerSettings performs platform-specific validation of the
  104. // hostconfig and config structures.
  105. func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
  106. warnings := []string{}
  107. sysInfo := sysinfo.New(true)
  108. if hostConfig.LxcConf.Len() > 0 && !strings.Contains(daemon.ExecutionDriver().Name(), "lxc") {
  109. return warnings, fmt.Errorf("Cannot use --lxc-conf with execdriver: %s", daemon.ExecutionDriver().Name())
  110. }
  111. // memory subsystem checks and adjustments
  112. if hostConfig.Memory != 0 && hostConfig.Memory < 4194304 {
  113. return warnings, fmt.Errorf("Minimum memory limit allowed is 4MB")
  114. }
  115. if hostConfig.Memory > 0 && !sysInfo.MemoryLimit {
  116. warnings = append(warnings, "Your kernel does not support memory limit capabilities. Limitation discarded.")
  117. logrus.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.")
  118. hostConfig.Memory = 0
  119. hostConfig.MemorySwap = -1
  120. }
  121. if hostConfig.Memory > 0 && hostConfig.MemorySwap != -1 && !sysInfo.SwapLimit {
  122. warnings = append(warnings, "Your kernel does not support swap limit capabilities, memory limited without swap.")
  123. logrus.Warnf("Your kernel does not support swap limit capabilities, memory limited without swap.")
  124. hostConfig.MemorySwap = -1
  125. }
  126. if hostConfig.Memory > 0 && hostConfig.MemorySwap > 0 && hostConfig.MemorySwap < hostConfig.Memory {
  127. return warnings, fmt.Errorf("Minimum memoryswap limit should be larger than memory limit, see usage.")
  128. }
  129. if hostConfig.Memory == 0 && hostConfig.MemorySwap > 0 {
  130. return warnings, fmt.Errorf("You should always set the Memory limit when using Memoryswap limit, see usage.")
  131. }
  132. if hostConfig.MemorySwappiness != nil && *hostConfig.MemorySwappiness != -1 && !sysInfo.MemorySwappiness {
  133. warnings = append(warnings, "Your kernel does not support memory swappiness capabilities, memory swappiness discarded.")
  134. logrus.Warnf("Your kernel does not support memory swappiness capabilities, memory swappiness discarded.")
  135. hostConfig.MemorySwappiness = nil
  136. }
  137. if hostConfig.MemorySwappiness != nil {
  138. swappiness := *hostConfig.MemorySwappiness
  139. if swappiness < -1 || swappiness > 100 {
  140. return warnings, fmt.Errorf("Invalid value: %v, valid memory swappiness range is 0-100.", swappiness)
  141. }
  142. }
  143. if hostConfig.KernelMemory > 0 && !sysInfo.KernelMemory {
  144. warnings = append(warnings, "Your kernel does not support kernel memory limit capabilities. Limitation discarded.")
  145. logrus.Warnf("Your kernel does not support kernel memory limit capabilities. Limitation discarded.")
  146. hostConfig.KernelMemory = 0
  147. }
  148. if hostConfig.KernelMemory > 0 && !checkKernelVersion(4, 0, 0) {
  149. warnings = append(warnings, "You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.")
  150. logrus.Warnf("You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.")
  151. }
  152. if hostConfig.CPUShares > 0 && !sysInfo.CPUShares {
  153. warnings = append(warnings, "Your kernel does not support CPU shares. Shares discarded.")
  154. logrus.Warnf("Your kernel does not support CPU shares. Shares discarded.")
  155. hostConfig.CPUShares = 0
  156. }
  157. if hostConfig.CPUPeriod > 0 && !sysInfo.CPUCfsPeriod {
  158. warnings = append(warnings, "Your kernel does not support CPU cfs period. Period discarded.")
  159. logrus.Warnf("Your kernel does not support CPU cfs period. Period discarded.")
  160. hostConfig.CPUPeriod = 0
  161. }
  162. if hostConfig.CPUQuota > 0 && !sysInfo.CPUCfsQuota {
  163. warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.")
  164. logrus.Warnf("Your kernel does not support CPU cfs quota. Quota discarded.")
  165. hostConfig.CPUQuota = 0
  166. }
  167. if (hostConfig.CpusetCpus != "" || hostConfig.CpusetMems != "") && !sysInfo.Cpuset {
  168. warnings = append(warnings, "Your kernel does not support cpuset. Cpuset discarded.")
  169. logrus.Warnf("Your kernel does not support cpuset. Cpuset discarded.")
  170. hostConfig.CpusetCpus = ""
  171. hostConfig.CpusetMems = ""
  172. }
  173. if hostConfig.BlkioWeight > 0 && !sysInfo.BlkioWeight {
  174. warnings = append(warnings, "Your kernel does not support Block I/O weight. Weight discarded.")
  175. logrus.Warnf("Your kernel does not support Block I/O weight. Weight discarded.")
  176. hostConfig.BlkioWeight = 0
  177. }
  178. if hostConfig.BlkioWeight > 0 && (hostConfig.BlkioWeight < 10 || hostConfig.BlkioWeight > 1000) {
  179. return warnings, fmt.Errorf("Range of blkio weight is from 10 to 1000.")
  180. }
  181. if hostConfig.OomKillDisable && !sysInfo.OomKillDisable {
  182. hostConfig.OomKillDisable = false
  183. return warnings, fmt.Errorf("Your kernel does not support oom kill disable.")
  184. }
  185. if sysInfo.IPv4ForwardingDisabled {
  186. warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.")
  187. logrus.Warnf("IPv4 forwarding is disabled. Networking will not work")
  188. }
  189. return warnings, nil
  190. }
  191. // checkConfigOptions checks for mutually incompatible config options
  192. func checkConfigOptions(config *Config) error {
  193. // Check for mutually incompatible config options
  194. if config.Bridge.Iface != "" && config.Bridge.IP != "" {
  195. return fmt.Errorf("You specified -b & --bip, mutually exclusive options. Please specify only one.")
  196. }
  197. if !config.Bridge.EnableIPTables && !config.Bridge.InterContainerCommunication {
  198. return fmt.Errorf("You specified --iptables=false with --icc=false. ICC uses iptables to function. Please set --icc or --iptables to true.")
  199. }
  200. if !config.Bridge.EnableIPTables && config.Bridge.EnableIPMasq {
  201. config.Bridge.EnableIPMasq = false
  202. }
  203. return nil
  204. }
  205. // checkSystem validates platform-specific requirements
  206. func checkSystem() error {
  207. if os.Geteuid() != 0 {
  208. return fmt.Errorf("The Docker daemon needs to be run as root")
  209. }
  210. if err := checkKernel(); err != nil {
  211. return err
  212. }
  213. return nil
  214. }
  215. // configureKernelSecuritySupport configures and validate security support for the kernel
  216. func configureKernelSecuritySupport(config *Config, driverName string) error {
  217. if config.EnableSelinuxSupport {
  218. if selinuxEnabled() {
  219. // As Docker on either btrfs or overlayFS and SELinux are incompatible at present, error on both being enabled
  220. if driverName == "btrfs" || driverName == "overlay" {
  221. return fmt.Errorf("SELinux is not supported with the %s graph driver", driverName)
  222. }
  223. logrus.Debug("SELinux enabled successfully")
  224. } else {
  225. logrus.Warn("Docker could not enable SELinux on the host system")
  226. }
  227. } else {
  228. selinuxSetDisabled()
  229. }
  230. return nil
  231. }
  232. // MigrateIfDownlevel is a wrapper for AUFS migration for downlevel
  233. func migrateIfDownlevel(driver graphdriver.Driver, root string) error {
  234. return migrateIfAufs(driver, root)
  235. }
  236. func configureSysInit(config *Config) (string, error) {
  237. localCopy := filepath.Join(config.Root, "init", fmt.Sprintf("dockerinit-%s", dockerversion.VERSION))
  238. sysInitPath := utils.DockerInitPath(localCopy)
  239. if sysInitPath == "" {
  240. return "", fmt.Errorf("Could not locate dockerinit: This usually means docker was built incorrectly. See https://docs.docker.com/contributing/devenvironment for official build instructions.")
  241. }
  242. if sysInitPath != localCopy {
  243. // When we find a suitable dockerinit binary (even if it's our local binary), we copy it into config.Root at localCopy for future use (so that the original can go away without that being a problem, for example during a package upgrade).
  244. if err := os.Mkdir(filepath.Dir(localCopy), 0700); err != nil && !os.IsExist(err) {
  245. return "", err
  246. }
  247. if _, err := fileutils.CopyFile(sysInitPath, localCopy); err != nil {
  248. return "", err
  249. }
  250. if err := os.Chmod(localCopy, 0700); err != nil {
  251. return "", err
  252. }
  253. sysInitPath = localCopy
  254. }
  255. return sysInitPath, nil
  256. }
  257. func isBridgeNetworkDisabled(config *Config) bool {
  258. return config.Bridge.Iface == disableNetworkBridge
  259. }
  260. func networkOptions(dconfig *Config) ([]nwconfig.Option, error) {
  261. options := []nwconfig.Option{}
  262. if dconfig == nil {
  263. return options, nil
  264. }
  265. if strings.TrimSpace(dconfig.DefaultNetwork) != "" {
  266. dn := strings.Split(dconfig.DefaultNetwork, ":")
  267. if len(dn) < 2 {
  268. return nil, fmt.Errorf("default network daemon config must be of the form NETWORKDRIVER:NETWORKNAME")
  269. }
  270. options = append(options, nwconfig.OptionDefaultDriver(dn[0]))
  271. options = append(options, nwconfig.OptionDefaultNetwork(strings.Join(dn[1:], ":")))
  272. } else {
  273. dd := runconfig.DefaultDaemonNetworkMode()
  274. dn := runconfig.DefaultDaemonNetworkMode().NetworkName()
  275. options = append(options, nwconfig.OptionDefaultDriver(string(dd)))
  276. options = append(options, nwconfig.OptionDefaultNetwork(dn))
  277. }
  278. if strings.TrimSpace(dconfig.NetworkKVStore) != "" {
  279. kv := strings.Split(dconfig.NetworkKVStore, ":")
  280. if len(kv) < 2 {
  281. return nil, fmt.Errorf("kv store daemon config must be of the form KV-PROVIDER:KV-URL")
  282. }
  283. options = append(options, nwconfig.OptionKVProvider(kv[0]))
  284. options = append(options, nwconfig.OptionKVProviderURL(strings.Join(kv[1:], ":")))
  285. }
  286. options = append(options, nwconfig.OptionLabels(dconfig.Labels))
  287. return options, nil
  288. }
  289. func initNetworkController(config *Config) (libnetwork.NetworkController, error) {
  290. netOptions, err := networkOptions(config)
  291. if err != nil {
  292. return nil, err
  293. }
  294. controller, err := libnetwork.New(netOptions...)
  295. if err != nil {
  296. return nil, fmt.Errorf("error obtaining controller instance: %v", err)
  297. }
  298. // Initialize default driver "null"
  299. if err := controller.ConfigureNetworkDriver("null", options.Generic{}); err != nil {
  300. return nil, fmt.Errorf("Error initializing null driver: %v", err)
  301. }
  302. // Initialize default network on "null"
  303. if _, err := controller.NewNetwork("null", "none"); err != nil {
  304. return nil, fmt.Errorf("Error creating default \"null\" network: %v", err)
  305. }
  306. // Initialize default driver "host"
  307. if err := controller.ConfigureNetworkDriver("host", options.Generic{}); err != nil {
  308. return nil, fmt.Errorf("Error initializing host driver: %v", err)
  309. }
  310. // Initialize default network on "host"
  311. if _, err := controller.NewNetwork("host", "host"); err != nil {
  312. return nil, fmt.Errorf("Error creating default \"host\" network: %v", err)
  313. }
  314. if !config.DisableBridge {
  315. // Initialize default driver "bridge"
  316. if err := initBridgeDriver(controller, config); err != nil {
  317. return nil, err
  318. }
  319. }
  320. return controller, nil
  321. }
  322. func initBridgeDriver(controller libnetwork.NetworkController, config *Config) error {
  323. option := options.Generic{
  324. "EnableIPForwarding": config.Bridge.EnableIPForward,
  325. "EnableIPTables": config.Bridge.EnableIPTables,
  326. "EnableUserlandProxy": config.Bridge.EnableUserlandProxy}
  327. if err := controller.ConfigureNetworkDriver("bridge", options.Generic{netlabel.GenericData: option}); err != nil {
  328. return fmt.Errorf("Error initializing bridge driver: %v", err)
  329. }
  330. netOption := options.Generic{
  331. "BridgeName": config.Bridge.Iface,
  332. "Mtu": config.Mtu,
  333. "EnableIPMasquerade": config.Bridge.EnableIPMasq,
  334. "EnableICC": config.Bridge.InterContainerCommunication,
  335. }
  336. if config.Bridge.IP != "" {
  337. ip, bipNet, err := net.ParseCIDR(config.Bridge.IP)
  338. if err != nil {
  339. return err
  340. }
  341. bipNet.IP = ip
  342. netOption["AddressIPv4"] = bipNet
  343. }
  344. if config.Bridge.FixedCIDR != "" {
  345. _, fCIDR, err := net.ParseCIDR(config.Bridge.FixedCIDR)
  346. if err != nil {
  347. return err
  348. }
  349. netOption["FixedCIDR"] = fCIDR
  350. }
  351. if config.Bridge.FixedCIDRv6 != "" {
  352. _, fCIDRv6, err := net.ParseCIDR(config.Bridge.FixedCIDRv6)
  353. if err != nil {
  354. return err
  355. }
  356. netOption["FixedCIDRv6"] = fCIDRv6
  357. }
  358. if config.Bridge.DefaultGatewayIPv4 != nil {
  359. netOption["DefaultGatewayIPv4"] = config.Bridge.DefaultGatewayIPv4
  360. }
  361. if config.Bridge.DefaultGatewayIPv6 != nil {
  362. netOption["DefaultGatewayIPv6"] = config.Bridge.DefaultGatewayIPv6
  363. }
  364. // --ip processing
  365. if config.Bridge.DefaultIP != nil {
  366. netOption["DefaultBindingIP"] = config.Bridge.DefaultIP
  367. }
  368. // Initialize default network on "bridge" with the same name
  369. _, err := controller.NewNetwork("bridge", "bridge",
  370. libnetwork.NetworkOptionGeneric(options.Generic{
  371. netlabel.GenericData: netOption,
  372. netlabel.EnableIPv6: config.Bridge.EnableIPv6,
  373. }))
  374. if err != nil {
  375. return fmt.Errorf("Error creating default \"bridge\" network: %v", err)
  376. }
  377. return nil
  378. }
  379. // setupInitLayer populates a directory with mountpoints suitable
  380. // for bind-mounting dockerinit into the container. The mountpoint is simply an
  381. // empty file at /.dockerinit
  382. //
  383. // This extra layer is used by all containers as the top-most ro layer. It protects
  384. // the container from unwanted side-effects on the rw layer.
  385. func setupInitLayer(initLayer string) error {
  386. for pth, typ := range map[string]string{
  387. "/dev/pts": "dir",
  388. "/dev/shm": "dir",
  389. "/proc": "dir",
  390. "/sys": "dir",
  391. "/.dockerinit": "file",
  392. "/.dockerenv": "file",
  393. "/etc/resolv.conf": "file",
  394. "/etc/hosts": "file",
  395. "/etc/hostname": "file",
  396. "/dev/console": "file",
  397. "/etc/mtab": "/proc/mounts",
  398. } {
  399. parts := strings.Split(pth, "/")
  400. prev := "/"
  401. for _, p := range parts[1:] {
  402. prev = filepath.Join(prev, p)
  403. syscall.Unlink(filepath.Join(initLayer, prev))
  404. }
  405. if _, err := os.Stat(filepath.Join(initLayer, pth)); err != nil {
  406. if os.IsNotExist(err) {
  407. if err := system.MkdirAll(filepath.Join(initLayer, filepath.Dir(pth)), 0755); err != nil {
  408. return err
  409. }
  410. switch typ {
  411. case "dir":
  412. if err := system.MkdirAll(filepath.Join(initLayer, pth), 0755); err != nil {
  413. return err
  414. }
  415. case "file":
  416. f, err := os.OpenFile(filepath.Join(initLayer, pth), os.O_CREATE, 0755)
  417. if err != nil {
  418. return err
  419. }
  420. f.Close()
  421. default:
  422. if err := os.Symlink(typ, filepath.Join(initLayer, pth)); err != nil {
  423. return err
  424. }
  425. }
  426. } else {
  427. return err
  428. }
  429. }
  430. }
  431. // Layer is ready to use, if it wasn't before.
  432. return nil
  433. }
  434. // NetworkAPIRouter implements a feature for server-experimental,
  435. // directly calling into libnetwork.
  436. func (daemon *Daemon) NetworkAPIRouter() func(w http.ResponseWriter, req *http.Request) {
  437. return nwapi.NewHTTPHandler(daemon.netController)
  438. }
  439. // registerLinks writes the links to a file.
  440. func (daemon *Daemon) registerLinks(container *Container, hostConfig *runconfig.HostConfig) error {
  441. if hostConfig == nil || hostConfig.Links == nil {
  442. return nil
  443. }
  444. for _, l := range hostConfig.Links {
  445. name, alias, err := parsers.ParseLink(l)
  446. if err != nil {
  447. return err
  448. }
  449. child, err := daemon.Get(name)
  450. if err != nil {
  451. //An error from daemon.Get() means this name could not be found
  452. return fmt.Errorf("Could not get container for %s", name)
  453. }
  454. for child.hostConfig.NetworkMode.IsContainer() {
  455. parts := strings.SplitN(string(child.hostConfig.NetworkMode), ":", 2)
  456. child, err = daemon.Get(parts[1])
  457. if err != nil {
  458. return fmt.Errorf("Could not get container for %s", parts[1])
  459. }
  460. }
  461. if child.hostConfig.NetworkMode.IsHost() {
  462. return runconfig.ErrConflictHostNetworkAndLinks
  463. }
  464. if err := daemon.registerLink(container, child, alias); err != nil {
  465. return err
  466. }
  467. }
  468. // After we load all the links into the daemon
  469. // set them to nil on the hostconfig
  470. hostConfig.Links = nil
  471. if err := container.writeHostConfig(); err != nil {
  472. return err
  473. }
  474. return nil
  475. }
  476. func (daemon *Daemon) newBaseContainer(id string) Container {
  477. return Container{
  478. CommonContainer: CommonContainer{
  479. ID: id,
  480. State: NewState(),
  481. execCommands: newExecStore(),
  482. root: daemon.containerRoot(id),
  483. },
  484. MountPoints: make(map[string]*mountPoint),
  485. Volumes: make(map[string]string),
  486. VolumesRW: make(map[string]bool),
  487. }
  488. }