diff --git a/daemon/create.go b/daemon/create.go index 05231dfcec..7e6b6519fe 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -266,7 +266,7 @@ func (daemon *Daemon) setRWLayer(container *container.Container) error { rwLayerOpts := &layer.CreateRWLayerOpts{ MountLabel: container.MountLabel, - InitFunc: daemon.getLayerInit(), + InitFunc: setupInitLayer(daemon.idMappings), StorageOpt: container.HostConfig.StorageOpt, } diff --git a/daemon/daemon.go b/daemon/daemon.go index c93415cd7d..335e6442f7 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -32,7 +32,6 @@ import ( "github.com/sirupsen/logrus" // register graph drivers _ "github.com/docker/docker/daemon/graphdriver/register" - "github.com/docker/docker/daemon/initlayer" "github.com/docker/docker/daemon/stats" dmetadata "github.com/docker/docker/distribution/metadata" "github.com/docker/docker/distribution/xfer" @@ -41,7 +40,6 @@ import ( "github.com/docker/docker/layer" "github.com/docker/docker/libcontainerd" "github.com/docker/docker/migrate/v1" - "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/locker" "github.com/docker/docker/pkg/plugingetter" @@ -1141,11 +1139,6 @@ func prepareTempDir(rootDir string, rootIDs idtools.IDPair) (string, error) { return tmpDir, idtools.MkdirAllAndChown(tmpDir, 0700, rootIDs) } -func (daemon *Daemon) setupInitLayer(initPath containerfs.ContainerFS) error { - rootIDs := daemon.idMappings.RootPair() - return initlayer.Setup(initPath, rootIDs) -} - func (daemon *Daemon) setGenericResources(conf *config.Config) error { genericResources, err := config.ParseGenericResources(conf.NodeGenericResources) if err != nil { diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index 55ff9f8574..670d564b8a 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -23,7 +23,7 @@ import ( containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/daemon/config" - "github.com/docker/docker/image" + "github.com/docker/docker/daemon/initlayer" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/idtools" @@ -1000,8 +1000,10 @@ func removeDefaultBridgeInterface() { } } -func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error { - return daemon.setupInitLayer +func setupInitLayer(idMappings *idtools.IDMappings) func(containerfs.ContainerFS) error { + return func(initPath containerfs.ContainerFS) error { + return initlayer.Setup(initPath, idMappings.RootPair()) + } } // Parse the remapped root (user namespace) option, which can be one of: @@ -1357,17 +1359,6 @@ func (daemon *Daemon) setDefaultIsolation() error { return nil } -func rootFSToAPIType(rootfs *image.RootFS) types.RootFS { - var layers []string - for _, l := range rootfs.DiffIDs { - layers = append(layers, l.String()) - } - return types.RootFS{ - Type: rootfs.Type, - Layers: layers, - } -} - // setupDaemonProcess sets various settings for the daemon's process func setupDaemonProcess(config *config.Config) error { // setup the daemons oom_score_adj diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index 7b5d954e98..50507e5fad 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -11,7 +11,6 @@ import ( containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" "github.com/docker/docker/daemon/config" - "github.com/docker/docker/image" "github.com/docker/docker/pkg/containerfs" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/idtools" @@ -54,7 +53,7 @@ func parseSecurityOpt(container *container.Container, config *containertypes.Hos return nil } -func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error { +func setupInitLayer(idMappings *idtools.IDMappings) func(containerfs.ContainerFS) error { return nil } @@ -629,17 +628,6 @@ func (daemon *Daemon) setDefaultIsolation() error { return nil } -func rootFSToAPIType(rootfs *image.RootFS) types.RootFS { - var layers []string - for _, l := range rootfs.DiffIDs { - layers = append(layers, l.String()) - } - return types.RootFS{ - Type: rootfs.Type, - Layers: layers, - } -} - func setupDaemonProcess(config *config.Config) error { return nil } diff --git a/daemon/image_inspect.go b/daemon/image_inspect.go index 066466e047..731057cf34 100644 --- a/daemon/image_inspect.go +++ b/daemon/image_inspect.go @@ -5,6 +5,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/image" "github.com/docker/docker/layer" "github.com/docker/docker/pkg/system" "github.com/pkg/errors" @@ -90,3 +91,14 @@ func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error) { return imageInspect, nil } + +func rootFSToAPIType(rootfs *image.RootFS) types.RootFS { + var layers []string + for _, l := range rootfs.DiffIDs { + layers = append(layers, l.String()) + } + return types.RootFS{ + Type: rootfs.Type, + Layers: layers, + } +}