|
@@ -23,6 +23,7 @@ import (
|
|
"github.com/docker/docker/api"
|
|
"github.com/docker/docker/api"
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/cliconfig"
|
|
"github.com/docker/docker/cliconfig"
|
|
|
|
+ "github.com/docker/docker/container"
|
|
"github.com/docker/docker/daemon/events"
|
|
"github.com/docker/docker/daemon/events"
|
|
"github.com/docker/docker/daemon/exec"
|
|
"github.com/docker/docker/daemon/exec"
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
@@ -84,17 +85,17 @@ func (e ErrImageDoesNotExist) Error() string {
|
|
}
|
|
}
|
|
|
|
|
|
type contStore struct {
|
|
type contStore struct {
|
|
- s map[string]*Container
|
|
|
|
|
|
+ s map[string]*container.Container
|
|
sync.Mutex
|
|
sync.Mutex
|
|
}
|
|
}
|
|
|
|
|
|
-func (c *contStore) Add(id string, cont *Container) {
|
|
|
|
|
|
+func (c *contStore) Add(id string, cont *container.Container) {
|
|
c.Lock()
|
|
c.Lock()
|
|
c.s[id] = cont
|
|
c.s[id] = cont
|
|
c.Unlock()
|
|
c.Unlock()
|
|
}
|
|
}
|
|
|
|
|
|
-func (c *contStore) Get(id string) *Container {
|
|
|
|
|
|
+func (c *contStore) Get(id string) *container.Container {
|
|
c.Lock()
|
|
c.Lock()
|
|
res := c.s[id]
|
|
res := c.s[id]
|
|
c.Unlock()
|
|
c.Unlock()
|
|
@@ -107,7 +108,7 @@ func (c *contStore) Delete(id string) {
|
|
c.Unlock()
|
|
c.Unlock()
|
|
}
|
|
}
|
|
|
|
|
|
-func (c *contStore) List() []*Container {
|
|
|
|
|
|
+func (c *contStore) List() []*container.Container {
|
|
containers := new(History)
|
|
containers := new(History)
|
|
c.Lock()
|
|
c.Lock()
|
|
for _, cont := range c.s {
|
|
for _, cont := range c.s {
|
|
@@ -155,7 +156,7 @@ type Daemon struct {
|
|
// - A partial container ID prefix (e.g. short ID) of any length that is
|
|
// - A partial container ID prefix (e.g. short ID) of any length that is
|
|
// unique enough to only return a single container object
|
|
// unique enough to only return a single container object
|
|
// If none of these searches succeed, an error is returned
|
|
// If none of these searches succeed, an error is returned
|
|
-func (daemon *Daemon) Get(prefixOrName string) (*Container, error) {
|
|
|
|
|
|
+func (daemon *Daemon) Get(prefixOrName string) (*container.Container, error) {
|
|
if containerByID := daemon.containers.Get(prefixOrName); containerByID != nil {
|
|
if containerByID := daemon.containers.Get(prefixOrName); containerByID != nil {
|
|
// prefix is an exact match to a full container ID
|
|
// prefix is an exact match to a full container ID
|
|
return containerByID, nil
|
|
return containerByID, nil
|
|
@@ -188,7 +189,7 @@ func (daemon *Daemon) Exists(id string) bool {
|
|
// IsPaused returns a bool indicating if the specified container is paused.
|
|
// IsPaused returns a bool indicating if the specified container is paused.
|
|
func (daemon *Daemon) IsPaused(id string) bool {
|
|
func (daemon *Daemon) IsPaused(id string) bool {
|
|
c, _ := daemon.Get(id)
|
|
c, _ := daemon.Get(id)
|
|
- return c.State.isPaused()
|
|
|
|
|
|
+ return c.State.IsPaused()
|
|
}
|
|
}
|
|
|
|
|
|
func (daemon *Daemon) containerRoot(id string) string {
|
|
func (daemon *Daemon) containerRoot(id string) string {
|
|
@@ -197,10 +198,10 @@ func (daemon *Daemon) containerRoot(id string) string {
|
|
|
|
|
|
// Load reads the contents of a container from disk
|
|
// Load reads the contents of a container from disk
|
|
// This is typically done at startup.
|
|
// This is typically done at startup.
|
|
-func (daemon *Daemon) load(id string) (*Container, error) {
|
|
|
|
|
|
+func (daemon *Daemon) load(id string) (*container.Container, error) {
|
|
container := daemon.newBaseContainer(id)
|
|
container := daemon.newBaseContainer(id)
|
|
|
|
|
|
- if err := container.fromDisk(); err != nil {
|
|
|
|
|
|
+ if err := container.FromDisk(); err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
|
|
@@ -212,7 +213,7 @@ func (daemon *Daemon) load(id string) (*Container, error) {
|
|
}
|
|
}
|
|
|
|
|
|
// Register makes a container object usable by the daemon as <container.ID>
|
|
// Register makes a container object usable by the daemon as <container.ID>
|
|
-func (daemon *Daemon) Register(container *Container) error {
|
|
|
|
|
|
+func (daemon *Daemon) Register(container *container.Container) error {
|
|
if daemon.Exists(container.ID) {
|
|
if daemon.Exists(container.ID) {
|
|
return fmt.Errorf("Container is already loaded")
|
|
return fmt.Errorf("Container is already loaded")
|
|
}
|
|
}
|
|
@@ -238,7 +239,7 @@ func (daemon *Daemon) Register(container *Container) error {
|
|
if container.IsRunning() {
|
|
if container.IsRunning() {
|
|
logrus.Debugf("killing old running container %s", container.ID)
|
|
logrus.Debugf("killing old running container %s", container.ID)
|
|
// Set exit code to 128 + SIGKILL (9) to properly represent unsuccessful exit
|
|
// Set exit code to 128 + SIGKILL (9) to properly represent unsuccessful exit
|
|
- container.setStoppedLocking(&execdriver.ExitStatus{ExitCode: 137})
|
|
|
|
|
|
+ container.SetStoppedLocking(&execdriver.ExitStatus{ExitCode: 137})
|
|
// use the current driver and ensure that the container is dead x.x
|
|
// use the current driver and ensure that the container is dead x.x
|
|
cmd := &execdriver.Command{
|
|
cmd := &execdriver.Command{
|
|
CommonCommand: execdriver.CommonCommand{
|
|
CommonCommand: execdriver.CommonCommand{
|
|
@@ -247,10 +248,10 @@ func (daemon *Daemon) Register(container *Container) error {
|
|
}
|
|
}
|
|
daemon.execDriver.Terminate(cmd)
|
|
daemon.execDriver.Terminate(cmd)
|
|
|
|
|
|
- container.unmountIpcMounts(mount.Unmount)
|
|
|
|
|
|
+ container.UnmountIpcMounts(mount.Unmount)
|
|
|
|
|
|
daemon.Unmount(container)
|
|
daemon.Unmount(container)
|
|
- if err := container.toDiskLocking(); err != nil {
|
|
|
|
|
|
+ if err := container.ToDiskLocking(); err != nil {
|
|
logrus.Errorf("Error saving stopped state to disk: %v", err)
|
|
logrus.Errorf("Error saving stopped state to disk: %v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -262,7 +263,7 @@ func (daemon *Daemon) Register(container *Container) error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) ensureName(container *Container) error {
|
|
|
|
|
|
+func (daemon *Daemon) ensureName(container *container.Container) error {
|
|
if container.Name == "" {
|
|
if container.Name == "" {
|
|
name, err := daemon.generateNewName(container.ID)
|
|
name, err := daemon.generateNewName(container.ID)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -270,7 +271,7 @@ func (daemon *Daemon) ensureName(container *Container) error {
|
|
}
|
|
}
|
|
container.Name = name
|
|
container.Name = name
|
|
|
|
|
|
- if err := container.toDiskLocking(); err != nil {
|
|
|
|
|
|
+ if err := container.ToDiskLocking(); err != nil {
|
|
logrus.Errorf("Error saving container name to disk: %v", err)
|
|
logrus.Errorf("Error saving container name to disk: %v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -279,7 +280,7 @@ func (daemon *Daemon) ensureName(container *Container) error {
|
|
|
|
|
|
func (daemon *Daemon) restore() error {
|
|
func (daemon *Daemon) restore() error {
|
|
type cr struct {
|
|
type cr struct {
|
|
- container *Container
|
|
|
|
|
|
+ container *container.Container
|
|
registered bool
|
|
registered bool
|
|
}
|
|
}
|
|
|
|
|
|
@@ -336,7 +337,7 @@ func (daemon *Daemon) restore() error {
|
|
for _, c := range containers {
|
|
for _, c := range containers {
|
|
group.Add(1)
|
|
group.Add(1)
|
|
|
|
|
|
- go func(container *Container, registered bool) {
|
|
|
|
|
|
+ go func(container *container.Container, registered bool) {
|
|
defer group.Done()
|
|
defer group.Done()
|
|
|
|
|
|
if !registered {
|
|
if !registered {
|
|
@@ -355,7 +356,7 @@ func (daemon *Daemon) restore() error {
|
|
|
|
|
|
// check the restart policy on the containers and restart any container with
|
|
// check the restart policy on the containers and restart any container with
|
|
// the restart policy of "always"
|
|
// the restart policy of "always"
|
|
- if daemon.configStore.AutoRestart && container.shouldRestart() {
|
|
|
|
|
|
+ if daemon.configStore.AutoRestart && container.ShouldRestart() {
|
|
logrus.Debugf("Starting container %s", container.ID)
|
|
logrus.Debugf("Starting container %s", container.ID)
|
|
|
|
|
|
if err := daemon.containerStart(container); err != nil {
|
|
if err := daemon.containerStart(container); err != nil {
|
|
@@ -474,7 +475,7 @@ func (daemon *Daemon) getEntrypointAndArgs(configEntrypoint *stringutils.StrSlic
|
|
return cmdSlice[0], cmdSlice[1:]
|
|
return cmdSlice[0], cmdSlice[1:]
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) newContainer(name string, config *runconfig.Config, imgID image.ID) (*Container, error) {
|
|
|
|
|
|
+func (daemon *Daemon) newContainer(name string, config *runconfig.Config, imgID image.ID) (*container.Container, error) {
|
|
var (
|
|
var (
|
|
id string
|
|
id string
|
|
err error
|
|
err error
|
|
@@ -493,7 +494,7 @@ func (daemon *Daemon) newContainer(name string, config *runconfig.Config, imgID
|
|
base.Path = entrypoint
|
|
base.Path = entrypoint
|
|
base.Args = args //FIXME: de-duplicate from config
|
|
base.Args = args //FIXME: de-duplicate from config
|
|
base.Config = config
|
|
base.Config = config
|
|
- base.hostConfig = &runconfig.HostConfig{}
|
|
|
|
|
|
+ base.HostConfig = &runconfig.HostConfig{}
|
|
base.ImageID = imgID
|
|
base.ImageID = imgID
|
|
base.NetworkSettings = &network.Settings{IsAnonymousEndpoint: noExplicitName}
|
|
base.NetworkSettings = &network.Settings{IsAnonymousEndpoint: noExplicitName}
|
|
base.Name = name
|
|
base.Name = name
|
|
@@ -516,7 +517,7 @@ func GetFullContainerName(name string) (string, error) {
|
|
}
|
|
}
|
|
|
|
|
|
// GetByName returns a container given a name.
|
|
// GetByName returns a container given a name.
|
|
-func (daemon *Daemon) GetByName(name string) (*Container, error) {
|
|
|
|
|
|
+func (daemon *Daemon) GetByName(name string) (*container.Container, error) {
|
|
fullName, err := GetFullContainerName(name)
|
|
fullName, err := GetFullContainerName(name)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
@@ -576,12 +577,12 @@ func (daemon *Daemon) GetLabels(id string) map[string]string {
|
|
// children returns all child containers of the container with the
|
|
// children returns all child containers of the container with the
|
|
// given name. The containers are returned as a map from the container
|
|
// given name. The containers are returned as a map from the container
|
|
// name to a pointer to Container.
|
|
// name to a pointer to Container.
|
|
-func (daemon *Daemon) children(name string) (map[string]*Container, error) {
|
|
|
|
|
|
+func (daemon *Daemon) children(name string) (map[string]*container.Container, error) {
|
|
name, err := GetFullContainerName(name)
|
|
name, err := GetFullContainerName(name)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
- children := make(map[string]*Container)
|
|
|
|
|
|
+ children := make(map[string]*container.Container)
|
|
|
|
|
|
err = daemon.containerGraphDB.Walk(name, func(p string, e *graphdb.Entity) error {
|
|
err = daemon.containerGraphDB.Walk(name, func(p string, e *graphdb.Entity) error {
|
|
c, err := daemon.Get(e.ID())
|
|
c, err := daemon.Get(e.ID())
|
|
@@ -609,7 +610,7 @@ func (daemon *Daemon) parents(name string) ([]string, error) {
|
|
return daemon.containerGraphDB.Parents(name)
|
|
return daemon.containerGraphDB.Parents(name)
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) registerLink(parent, child *Container, alias string) error {
|
|
|
|
|
|
+func (daemon *Daemon) registerLink(parent, child *container.Container, alias string) error {
|
|
fullName := filepath.Join(parent.Name, alias)
|
|
fullName := filepath.Join(parent.Name, alias)
|
|
if !daemon.containerGraphDB.Exists(fullName) {
|
|
if !daemon.containerGraphDB.Exists(fullName) {
|
|
_, err := daemon.containerGraphDB.Set(fullName, child.ID)
|
|
_, err := daemon.containerGraphDB.Set(fullName, child.ID)
|
|
@@ -830,7 +831,7 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
|
|
|
|
|
|
d.ID = trustKey.PublicKey().KeyID()
|
|
d.ID = trustKey.PublicKey().KeyID()
|
|
d.repository = daemonRepo
|
|
d.repository = daemonRepo
|
|
- d.containers = &contStore{s: make(map[string]*Container)}
|
|
|
|
|
|
+ d.containers = &contStore{s: make(map[string]*container.Container)}
|
|
d.execCommands = exec.NewStore()
|
|
d.execCommands = exec.NewStore()
|
|
d.tagStore = tagStore
|
|
d.tagStore = tagStore
|
|
d.distributionPool = distributionPool
|
|
d.distributionPool = distributionPool
|
|
@@ -861,9 +862,9 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
|
|
return d, nil
|
|
return d, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) shutdownContainer(c *Container) error {
|
|
|
|
|
|
+func (daemon *Daemon) shutdownContainer(c *container.Container) error {
|
|
// TODO(windows): Handle docker restart with paused containers
|
|
// TODO(windows): Handle docker restart with paused containers
|
|
- if c.isPaused() {
|
|
|
|
|
|
+ if c.IsPaused() {
|
|
// To terminate a process in freezer cgroup, we should send
|
|
// To terminate a process in freezer cgroup, we should send
|
|
// SIGTERM to this process then unfreeze it, and the process will
|
|
// SIGTERM to this process then unfreeze it, and the process will
|
|
// force to terminate immediately.
|
|
// force to terminate immediately.
|
|
@@ -906,20 +907,20 @@ func (daemon *Daemon) Shutdown() error {
|
|
if daemon.containers != nil {
|
|
if daemon.containers != nil {
|
|
group := sync.WaitGroup{}
|
|
group := sync.WaitGroup{}
|
|
logrus.Debug("starting clean shutdown of all containers...")
|
|
logrus.Debug("starting clean shutdown of all containers...")
|
|
- for _, container := range daemon.List() {
|
|
|
|
- if !container.IsRunning() {
|
|
|
|
|
|
+ for _, cont := range daemon.List() {
|
|
|
|
+ if !cont.IsRunning() {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- logrus.Debugf("stopping %s", container.ID)
|
|
|
|
|
|
+ logrus.Debugf("stopping %s", cont.ID)
|
|
group.Add(1)
|
|
group.Add(1)
|
|
- go func(c *Container) {
|
|
|
|
|
|
+ go func(c *container.Container) {
|
|
defer group.Done()
|
|
defer group.Done()
|
|
if err := daemon.shutdownContainer(c); err != nil {
|
|
if err := daemon.shutdownContainer(c); err != nil {
|
|
logrus.Errorf("Stop container error: %v", err)
|
|
logrus.Errorf("Stop container error: %v", err)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
logrus.Debugf("container stopped %s", c.ID)
|
|
logrus.Debugf("container stopped %s", c.ID)
|
|
- }(container)
|
|
|
|
|
|
+ }(cont)
|
|
}
|
|
}
|
|
group.Wait()
|
|
group.Wait()
|
|
}
|
|
}
|
|
@@ -948,9 +949,9 @@ func (daemon *Daemon) Shutdown() error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-// Mount sets container.basefs
|
|
|
|
|
|
+// Mount sets container.BaseFS
|
|
// (is it not set coming in? why is it unset?)
|
|
// (is it not set coming in? why is it unset?)
|
|
-func (daemon *Daemon) Mount(container *Container) error {
|
|
|
|
|
|
+func (daemon *Daemon) Mount(container *container.Container) error {
|
|
var layerID layer.ChainID
|
|
var layerID layer.ChainID
|
|
if container.ImageID != "" {
|
|
if container.ImageID != "" {
|
|
img, err := daemon.imageStore.Get(container.ImageID)
|
|
img, err := daemon.imageStore.Get(container.ImageID)
|
|
@@ -959,7 +960,7 @@ func (daemon *Daemon) Mount(container *Container) error {
|
|
}
|
|
}
|
|
layerID = img.RootFS.ChainID()
|
|
layerID = img.RootFS.ChainID()
|
|
}
|
|
}
|
|
- rwlayer, err := daemon.layerStore.Mount(container.ID, layerID, container.getMountLabel(), daemon.setupInitLayer)
|
|
|
|
|
|
+ rwlayer, err := daemon.layerStore.Mount(container.ID, layerID, container.GetMountLabel(), daemon.setupInitLayer)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -969,56 +970,56 @@ func (daemon *Daemon) Mount(container *Container) error {
|
|
}
|
|
}
|
|
logrus.Debugf("container mounted via layerStore: %v", dir)
|
|
logrus.Debugf("container mounted via layerStore: %v", dir)
|
|
|
|
|
|
- if container.basefs != dir {
|
|
|
|
|
|
+ if container.BaseFS != dir {
|
|
// The mount path reported by the graph driver should always be trusted on Windows, since the
|
|
// The mount path reported by the graph driver should always be trusted on Windows, since the
|
|
// volume path for a given mounted layer may change over time. This should only be an error
|
|
// volume path for a given mounted layer may change over time. This should only be an error
|
|
// on non-Windows operating systems.
|
|
// on non-Windows operating systems.
|
|
- if container.basefs != "" && runtime.GOOS != "windows" {
|
|
|
|
|
|
+ if container.BaseFS != "" && runtime.GOOS != "windows" {
|
|
daemon.Unmount(container)
|
|
daemon.Unmount(container)
|
|
return fmt.Errorf("Error: driver %s is returning inconsistent paths for container %s ('%s' then '%s')",
|
|
return fmt.Errorf("Error: driver %s is returning inconsistent paths for container %s ('%s' then '%s')",
|
|
- daemon.driver, container.ID, container.basefs, dir)
|
|
|
|
|
|
+ daemon.driver, container.ID, container.BaseFS, dir)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- container.basefs = dir // TODO: combine these fields
|
|
|
|
- container.rwlayer = rwlayer
|
|
|
|
|
|
+ container.BaseFS = dir // TODO: combine these fields
|
|
|
|
+ container.RWLayer = rwlayer
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
// Unmount unsets the container base filesystem
|
|
// Unmount unsets the container base filesystem
|
|
-func (daemon *Daemon) Unmount(container *Container) {
|
|
|
|
|
|
+func (daemon *Daemon) Unmount(container *container.Container) {
|
|
if err := daemon.layerStore.Unmount(container.ID); err != nil {
|
|
if err := daemon.layerStore.Unmount(container.ID); err != nil {
|
|
logrus.Errorf("Error unmounting container %s: %s", container.ID, err)
|
|
logrus.Errorf("Error unmounting container %s: %s", container.ID, err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Run uses the execution driver to run a given container
|
|
// Run uses the execution driver to run a given container
|
|
-func (daemon *Daemon) Run(c *Container, pipes *execdriver.Pipes, startCallback execdriver.DriverCallback) (execdriver.ExitStatus, error) {
|
|
|
|
|
|
+func (daemon *Daemon) Run(c *container.Container, pipes *execdriver.Pipes, startCallback execdriver.DriverCallback) (execdriver.ExitStatus, error) {
|
|
hooks := execdriver.Hooks{
|
|
hooks := execdriver.Hooks{
|
|
Start: startCallback,
|
|
Start: startCallback,
|
|
}
|
|
}
|
|
hooks.PreStart = append(hooks.PreStart, func(processConfig *execdriver.ProcessConfig, pid int, chOOM <-chan struct{}) error {
|
|
hooks.PreStart = append(hooks.PreStart, func(processConfig *execdriver.ProcessConfig, pid int, chOOM <-chan struct{}) error {
|
|
return daemon.setNetworkNamespaceKey(c.ID, pid)
|
|
return daemon.setNetworkNamespaceKey(c.ID, pid)
|
|
})
|
|
})
|
|
- return daemon.execDriver.Run(c.command, pipes, hooks)
|
|
|
|
|
|
+ return daemon.execDriver.Run(c.Command, pipes, hooks)
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) kill(c *Container, sig int) error {
|
|
|
|
- return daemon.execDriver.Kill(c.command, sig)
|
|
|
|
|
|
+func (daemon *Daemon) kill(c *container.Container, sig int) error {
|
|
|
|
+ return daemon.execDriver.Kill(c.Command, sig)
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) stats(c *Container) (*execdriver.ResourceStats, error) {
|
|
|
|
|
|
+func (daemon *Daemon) stats(c *container.Container) (*execdriver.ResourceStats, error) {
|
|
return daemon.execDriver.Stats(c.ID)
|
|
return daemon.execDriver.Stats(c.ID)
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) subscribeToContainerStats(c *Container) chan interface{} {
|
|
|
|
|
|
+func (daemon *Daemon) subscribeToContainerStats(c *container.Container) chan interface{} {
|
|
return daemon.statsCollector.collect(c)
|
|
return daemon.statsCollector.collect(c)
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) unsubscribeToContainerStats(c *Container, ch chan interface{}) {
|
|
|
|
|
|
+func (daemon *Daemon) unsubscribeToContainerStats(c *container.Container, ch chan interface{}) {
|
|
daemon.statsCollector.unsubscribe(c, ch)
|
|
daemon.statsCollector.unsubscribe(c, ch)
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) changes(container *Container) ([]archive.Change, error) {
|
|
|
|
|
|
+func (daemon *Daemon) changes(container *container.Container) ([]archive.Change, error) {
|
|
return daemon.layerStore.Changes(container.ID)
|
|
return daemon.layerStore.Changes(container.ID)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1343,7 +1344,7 @@ func tempDir(rootDir string, rootUID, rootGID int) (string, error) {
|
|
return tmpDir, idtools.MkdirAllAs(tmpDir, 0700, rootUID, rootGID)
|
|
return tmpDir, idtools.MkdirAllAs(tmpDir, 0700, rootUID, rootGID)
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) setHostConfig(container *Container, hostConfig *runconfig.HostConfig) error {
|
|
|
|
|
|
+func (daemon *Daemon) setHostConfig(container *container.Container, hostConfig *runconfig.HostConfig) error {
|
|
container.Lock()
|
|
container.Lock()
|
|
if err := parseSecurityOpt(container, hostConfig); err != nil {
|
|
if err := parseSecurityOpt(container, hostConfig); err != nil {
|
|
container.Unlock()
|
|
container.Unlock()
|
|
@@ -1365,8 +1366,8 @@ func (daemon *Daemon) setHostConfig(container *Container, hostConfig *runconfig.
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
- container.hostConfig = hostConfig
|
|
|
|
- container.toDisk()
|
|
|
|
|
|
+ container.HostConfig = hostConfig
|
|
|
|
+ container.ToDisk()
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1462,7 +1463,7 @@ func (daemon *Daemon) IsShuttingDown() bool {
|
|
}
|
|
}
|
|
|
|
|
|
// GetContainerStats collects all the stats published by a container
|
|
// GetContainerStats collects all the stats published by a container
|
|
-func (daemon *Daemon) GetContainerStats(container *Container) (*execdriver.ResourceStats, error) {
|
|
|
|
|
|
+func (daemon *Daemon) GetContainerStats(container *container.Container) (*execdriver.ResourceStats, error) {
|
|
stats, err := daemon.stats(container)
|
|
stats, err := daemon.stats(container)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
@@ -1478,7 +1479,7 @@ func (daemon *Daemon) GetContainerStats(container *Container) (*execdriver.Resou
|
|
return stats, nil
|
|
return stats, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) getNetworkStats(c *Container) ([]*libcontainer.NetworkInterface, error) {
|
|
|
|
|
|
+func (daemon *Daemon) getNetworkStats(c *container.Container) ([]*libcontainer.NetworkInterface, error) {
|
|
var list []*libcontainer.NetworkInterface
|
|
var list []*libcontainer.NetworkInterface
|
|
|
|
|
|
sb, err := daemon.netController.SandboxByID(c.NetworkSettings.SandboxID)
|
|
sb, err := daemon.netController.SandboxByID(c.NetworkSettings.SandboxID)
|
|
@@ -1501,8 +1502,8 @@ func (daemon *Daemon) getNetworkStats(c *Container) ([]*libcontainer.NetworkInte
|
|
|
|
|
|
// newBaseContainer creates a new container with its initial
|
|
// newBaseContainer creates a new container with its initial
|
|
// configuration based on the root storage from the daemon.
|
|
// configuration based on the root storage from the daemon.
|
|
-func (daemon *Daemon) newBaseContainer(id string) *Container {
|
|
|
|
- return newBaseContainer(id, daemon.containerRoot(id))
|
|
|
|
|
|
+func (daemon *Daemon) newBaseContainer(id string) *container.Container {
|
|
|
|
+ return container.NewBaseContainer(id, daemon.containerRoot(id))
|
|
}
|
|
}
|
|
|
|
|
|
func convertLnNetworkStats(name string, stats *lntypes.InterfaceStatistics) *libcontainer.NetworkInterface {
|
|
func convertLnNetworkStats(name string, stats *lntypes.InterfaceStatistics) *libcontainer.NetworkInterface {
|
|
@@ -1517,3 +1518,10 @@ func convertLnNetworkStats(name string, stats *lntypes.InterfaceStatistics) *lib
|
|
n.TxDropped = stats.TxDropped
|
|
n.TxDropped = stats.TxDropped
|
|
return n
|
|
return n
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func validateID(id string) error {
|
|
|
|
+ if id == "" {
|
|
|
|
+ return derr.ErrorCodeEmptyID
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|