diff options
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index e25ffaa03..b3e474836 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -56,6 +56,10 @@ var ( // mutable layer, and the rest is the RootFS: the set of immutable layers // that make up the image on which the container is based. func (c *Container) rootFsSize() (int64, error) { + if c.config.Rootfs != "" { + return 0, nil + } + container, err := c.runtime.store.Container(c.ID()) if err != nil { return 0, err @@ -93,6 +97,18 @@ func (c *Container) rootFsSize() (int64, error) { // rwSize Gets the size of the mutable top layer of the container. func (c *Container) rwSize() (int64, error) { + if c.config.Rootfs != "" { + var size int64 + err := filepath.Walk(c.config.Rootfs, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + size += info.Size() + return nil + }) + return size, err + } + container, err := c.runtime.store.Container(c.ID()) if err != nil { return 0, err @@ -205,7 +221,7 @@ func (c *Container) setupStorage(ctx context.Context) error { } // Need both an image ID and image name, plus a bool telling us whether to use the image configuration - if c.config.RootfsImageID == "" || c.config.RootfsImageName == "" { + if c.config.Rootfs == "" && (c.config.RootfsImageID == "" || c.config.RootfsImageName == "") { return errors.Wrapf(ErrInvalidArg, "must provide image ID and image name to use an image") } @@ -691,9 +707,12 @@ func (c *Container) mountStorage() (err error) { } } - mountPoint, err := c.runtime.storageService.MountContainerImage(c.ID()) - if err != nil { - return errors.Wrapf(err, "error mounting storage for container %s", c.ID()) + mountPoint := c.config.Rootfs + if mountPoint == "" { + mountPoint, err = c.runtime.storageService.MountContainerImage(c.ID()) + if err != nil { + return errors.Wrapf(err, "error mounting storage for container %s", c.ID()) + } } c.state.Mounted = true c.state.Mountpoint = mountPoint @@ -796,6 +815,9 @@ func (c *Container) cleanupStorage() error { } } } + if c.config.Rootfs != "" { + return nil + } // Also unmount storage if err := c.runtime.storageService.UnmountContainerImage(c.ID()); err != nil { @@ -1154,7 +1176,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { return nil, errors.Wrapf(err, "error setting up OCI Hooks") } // Bind builtin image volumes - if c.config.ImageVolumes { + if c.config.Rootfs == "" && c.config.ImageVolumes { if err := c.addImageVolumes(ctx, &g); err != nil { return nil, errors.Wrapf(err, "error mounting image volumes") } @@ -1235,8 +1257,10 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { } } - if err := idtools.MkdirAllAs(c.state.RealMountpoint, 0700, c.RootUID(), c.RootGID()); err != nil { - return nil, err + if c.config.Rootfs == "" { + if err := idtools.MkdirAllAs(c.state.RealMountpoint, 0700, c.RootUID(), c.RootGID()); err != nil { + return nil, err + } } g.SetRootPath(c.state.RealMountpoint) |