summaryrefslogtreecommitdiff
path: root/cmd/podman/images
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/images')
-rw-r--r--cmd/podman/images/build.go58
-rw-r--r--cmd/podman/images/diff.go6
-rw-r--r--cmd/podman/images/exists.go4
-rw-r--r--cmd/podman/images/history.go4
-rw-r--r--cmd/podman/images/image.go6
-rw-r--r--cmd/podman/images/images.go4
-rw-r--r--cmd/podman/images/import.go6
-rw-r--r--cmd/podman/images/inspect.go6
-rw-r--r--cmd/podman/images/list.go57
-rw-r--r--cmd/podman/images/load.go8
-rw-r--r--cmd/podman/images/mount.go139
-rw-r--r--cmd/podman/images/prune.go8
-rw-r--r--cmd/podman/images/pull.go7
-rw-r--r--cmd/podman/images/push.go7
-rw-r--r--cmd/podman/images/rm.go6
-rw-r--r--cmd/podman/images/rmi.go4
-rw-r--r--cmd/podman/images/save.go10
-rw-r--r--cmd/podman/images/search.go6
-rw-r--r--cmd/podman/images/sign.go4
-rw-r--r--cmd/podman/images/tag.go4
-rw-r--r--cmd/podman/images/tree.go4
-rw-r--r--cmd/podman/images/trust.go6
-rw-r--r--cmd/podman/images/trust_set.go8
-rw-r--r--cmd/podman/images/trust_show.go4
-rw-r--r--cmd/podman/images/unmount.go71
-rw-r--r--cmd/podman/images/untag.go4
26 files changed, 332 insertions, 119 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 3ea74b4af..400f960cc 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -10,9 +10,9 @@ import (
buildahCLI "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/pkg/config"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/cmd/podman/utils"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/utils"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/docker/go-units"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
@@ -138,36 +138,9 @@ func build(cmd *cobra.Command, args []string) error {
return errors.New("cannot specify --squash, --squash-all and --layers options together")
}
- contextDir, containerFiles, err := extractContextAndFiles(args, buildOpts.File)
- if err != nil {
- return err
- }
-
- ie, err := registry.NewImageEngine(cmd, args)
- if err != nil {
- return err
- }
-
- apiBuildOpts, err := buildFlagsWrapperToOptions(cmd, contextDir, &buildOpts)
- if err != nil {
- return err
- }
-
- _, err = ie.Build(registry.GetContext(), containerFiles, *apiBuildOpts)
- return err
-}
-
-// extractContextAndFiles parses args and files to extract a context directory
-// and {Container,Docker}files.
-//
-// TODO: this was copied and altered from the v1 client which in turn was
-// copied and altered from the Buildah code. Ideally, all of this code should
-// be cleanly consolidated into a package that is shared between Buildah and
-// Podman.
-func extractContextAndFiles(args, files []string) (string, []string, error) {
// Extract container files from the CLI (i.e., --file/-f) first.
var containerFiles []string
- for _, f := range files {
+ for _, f := range buildOpts.File {
if f == "-" {
containerFiles = append(containerFiles, "/dev/stdin")
} else {
@@ -181,7 +154,7 @@ func extractContextAndFiles(args, files []string) (string, []string, error) {
// The context directory could be a URL. Try to handle that.
tempDir, subDir, err := imagebuildah.TempDirForURL("", "buildah", args[0])
if err != nil {
- return "", nil, errors.Wrapf(err, "error prepping temporary context directory")
+ return errors.Wrapf(err, "error prepping temporary context directory")
}
if tempDir != "" {
// We had to download it to a temporary directory.
@@ -196,7 +169,7 @@ func extractContextAndFiles(args, files []string) (string, []string, error) {
// Nope, it was local. Use it as is.
absDir, err := filepath.Abs(args[0])
if err != nil {
- return "", nil, errors.Wrapf(err, "error determining path to directory %q", args[0])
+ return errors.Wrapf(err, "error determining path to directory %q", args[0])
}
contextDir = absDir
}
@@ -212,7 +185,7 @@ func extractContextAndFiles(args, files []string) (string, []string, error) {
}
absFile, err := filepath.Abs(containerFiles[i])
if err != nil {
- return "", nil, errors.Wrapf(err, "error determining path to file %q", containerFiles[i])
+ return errors.Wrapf(err, "error determining path to file %q", containerFiles[i])
}
contextDir = filepath.Dir(absFile)
break
@@ -220,10 +193,10 @@ func extractContextAndFiles(args, files []string) (string, []string, error) {
}
if contextDir == "" {
- return "", nil, errors.Errorf("no context directory and no Containerfile specified")
+ return errors.Errorf("no context directory and no Containerfile specified")
}
if !utils.IsDir(contextDir) {
- return "", nil, errors.Errorf("context must be a directory: %q", contextDir)
+ return errors.Errorf("context must be a directory: %q", contextDir)
}
if len(containerFiles) == 0 {
if utils.FileExists(filepath.Join(contextDir, "Containerfile")) {
@@ -233,7 +206,18 @@ func extractContextAndFiles(args, files []string) (string, []string, error) {
}
}
- return contextDir, containerFiles, nil
+ ie, err := registry.NewImageEngine(cmd, args)
+ if err != nil {
+ return err
+ }
+
+ apiBuildOpts, err := buildFlagsWrapperToOptions(cmd, contextDir, &buildOpts)
+ if err != nil {
+ return err
+ }
+
+ _, err = ie.Build(registry.GetContext(), containerFiles, *apiBuildOpts)
+ return err
}
// buildFlagsWrapperToOptions converts the local build flags to the build options used
diff --git a/cmd/podman/images/diff.go b/cmd/podman/images/diff.go
index 10a1c06ec..26147345e 100644
--- a/cmd/podman/images/diff.go
+++ b/cmd/podman/images/diff.go
@@ -1,9 +1,9 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/cmd/podman/report"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/report"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
diff --git a/cmd/podman/images/exists.go b/cmd/podman/images/exists.go
index 7e05ea8f7..31bdc791e 100644
--- a/cmd/podman/images/exists.go
+++ b/cmd/podman/images/exists.go
@@ -1,8 +1,8 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/history.go b/cmd/podman/images/history.go
index 3732e6e03..ef5b4be26 100644
--- a/cmd/podman/images/history.go
+++ b/cmd/podman/images/history.go
@@ -10,8 +10,8 @@ import (
"time"
"unicode"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/spf13/cobra"
diff --git a/cmd/podman/images/image.go b/cmd/podman/images/image.go
index 89badd035..abf6bf736 100644
--- a/cmd/podman/images/image.go
+++ b/cmd/podman/images/image.go
@@ -1,9 +1,9 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/cmd/podman/validate"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/validate"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/images.go b/cmd/podman/images/images.go
index 0a77946c7..14ea01047 100644
--- a/cmd/podman/images/images.go
+++ b/cmd/podman/images/images.go
@@ -3,8 +3,8 @@ package images
import (
"strings"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/import.go b/cmd/podman/images/import.go
index 6b4b4f6b6..e605ddfc6 100644
--- a/cmd/podman/images/import.go
+++ b/cmd/podman/images/import.go
@@ -4,9 +4,9 @@ import (
"context"
"fmt"
- "github.com/containers/libpod/v2/cmd/podman/parse"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/parse"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
"github.com/spf13/cobra"
diff --git a/cmd/podman/images/inspect.go b/cmd/podman/images/inspect.go
index c6ef503bf..065dfaed2 100644
--- a/cmd/podman/images/inspect.go
+++ b/cmd/podman/images/inspect.go
@@ -1,9 +1,9 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/inspect"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/inspect"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go
index 37ff491c3..4552901f7 100644
--- a/cmd/podman/images/list.go
+++ b/cmd/podman/images/list.go
@@ -1,7 +1,6 @@
package images
import (
- "errors"
"fmt"
"os"
"sort"
@@ -11,9 +10,11 @@ import (
"time"
"unicode"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/image/v5/docker/reference"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/docker/go-units"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -98,7 +99,10 @@ func images(cmd *cobra.Command, args []string) error {
return err
}
- imgs := sortImages(summaries)
+ imgs, err := sortImages(summaries)
+ if err != nil {
+ return err
+ }
switch {
case listFlag.quiet:
return writeID(imgs)
@@ -170,14 +174,18 @@ func writeTemplate(imgs []imageReporter) error {
return tmpl.Execute(w, imgs)
}
-func sortImages(imageS []*entities.ImageSummary) []imageReporter {
+func sortImages(imageS []*entities.ImageSummary) ([]imageReporter, error) {
imgs := make([]imageReporter, 0, len(imageS))
+ var err error
for _, e := range imageS {
var h imageReporter
if len(e.RepoTags) > 0 {
for _, tag := range e.RepoTags {
h.ImageSummary = *e
- h.Repository, h.Tag = tokenRepoTag(tag)
+ h.Repository, h.Tag, err = tokenRepoTag(tag)
+ if err != nil {
+ return nil, errors.Wrapf(err, "error parsing repository tag %q:", tag)
+ }
imgs = append(imgs, h)
}
} else {
@@ -189,23 +197,32 @@ func sortImages(imageS []*entities.ImageSummary) []imageReporter {
}
sort.Slice(imgs, sortFunc(listFlag.sort, imgs))
- return imgs
+ return imgs, err
}
-func tokenRepoTag(tag string) (string, string) {
- tokens := strings.Split(tag, ":")
- switch len(tokens) {
- case 0:
- return tag, ""
- case 1:
- return tokens[0], ""
- case 2:
- return tokens[0], tokens[1]
- case 3:
- return tokens[0] + ":" + tokens[1], tokens[2]
- default:
- return "<N/A>", ""
+func tokenRepoTag(ref string) (string, string, error) {
+
+ if ref == "<none>:<none>" {
+ return "<none>", "<none>", nil
+ }
+
+ repo, err := reference.Parse(ref)
+ if err != nil {
+ return "", "", err
+ }
+
+ named, ok := repo.(reference.Named)
+ if !ok {
+ return ref, "", nil
}
+
+ tagged, ok := repo.(reference.Tagged)
+ if !ok {
+ return named.Name(), "", nil
+ }
+
+ return named.Name(), tagged.Tag(), nil
+
}
func sortFunc(key string, data []imageReporter) func(i, j int) bool {
diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go
index df7baae22..cc8e71814 100644
--- a/cmd/podman/images/load.go
+++ b/cmd/podman/images/load.go
@@ -9,10 +9,10 @@ import (
"strings"
"github.com/containers/image/v5/docker/reference"
- "github.com/containers/libpod/v2/cmd/podman/parse"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
- "github.com/containers/libpod/v2/pkg/util"
+ "github.com/containers/podman/v2/cmd/podman/parse"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
diff --git a/cmd/podman/images/mount.go b/cmd/podman/images/mount.go
new file mode 100644
index 000000000..fac06e324
--- /dev/null
+++ b/cmd/podman/images/mount.go
@@ -0,0 +1,139 @@
+package images
+
+import (
+ "fmt"
+ "os"
+ "text/tabwriter"
+ "text/template"
+
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/utils"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+ "github.com/spf13/pflag"
+)
+
+var (
+ mountDescription = `podman image mount
+ Lists all mounted images mount points if no images is specified
+
+ podman image mount IMAGE-NAME-OR-ID
+ Mounts the specified image and prints the mountpoint
+`
+
+ mountCommand = &cobra.Command{
+ Use: "mount [flags] [IMAGE...]",
+ Short: "Mount an images's root filesystem",
+ Long: mountDescription,
+ RunE: mount,
+ Example: `podman image mount imgID
+ podman image mount imgID1 imgID2 imgID3
+ podman image mount
+ podman image mount --all`,
+ Annotations: map[string]string{
+ registry.UnshareNSRequired: "",
+ registry.ParentNSRequired: "",
+ },
+ }
+)
+
+var (
+ mountOpts entities.ImageMountOptions
+)
+
+func mountFlags(flags *pflag.FlagSet) {
+ flags.BoolVarP(&mountOpts.All, "all", "a", false, "Mount all images")
+ flags.StringVar(&mountOpts.Format, "format", "", "Print the mounted images in specified format (json)")
+}
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: mountCommand,
+ Parent: imageCmd,
+ })
+ mountFlags(mountCommand.Flags())
+}
+
+func mount(_ *cobra.Command, args []string) error {
+ var (
+ errs utils.OutputErrors
+ )
+ if len(args) > 0 && mountOpts.All {
+ return errors.New("when using the --all switch, you may not pass any image names or IDs")
+ }
+ reports, err := registry.ImageEngine().Mount(registry.GetContext(), args, mountOpts)
+ if err != nil {
+ return err
+ }
+ if len(args) > 0 || mountOpts.All {
+ for _, r := range reports {
+ if r.Err == nil {
+ fmt.Println(r.Path)
+ continue
+ }
+ errs = append(errs, r.Err)
+ }
+ return errs.PrintErrors()
+ }
+
+ switch mountOpts.Format {
+ case "json":
+ return printJSON(reports)
+ case "":
+ // do nothing
+ default:
+ return errors.Errorf("unknown --format argument: %s", mountOpts.Format)
+ }
+
+ mrs := make([]mountReporter, 0, len(reports))
+ for _, r := range reports {
+ mrs = append(mrs, mountReporter{r})
+ }
+ row := "{{.ID}} {{.Path}}\n"
+ format := "{{range . }}" + row + "{{end}}"
+ tmpl, err := template.New("mounts").Parse(format)
+ if err != nil {
+ return err
+ }
+ w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
+ defer w.Flush()
+ return tmpl.Execute(w, mrs)
+}
+
+func printJSON(reports []*entities.ImageMountReport) error {
+ type jreport struct {
+ ID string `json:"id"`
+ Names []string
+ Repositories []string
+ Mountpoint string `json:"mountpoint"`
+ }
+ jreports := make([]jreport, 0, len(reports))
+
+ for _, r := range reports {
+ jreports = append(jreports, jreport{
+ ID: r.Id,
+ Names: []string{r.Name},
+ Repositories: r.Repositories,
+ Mountpoint: r.Path,
+ })
+ }
+ b, err := json.MarshalIndent(jreports, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(b))
+ return nil
+}
+
+type mountReporter struct {
+ *entities.ImageMountReport
+}
+
+func (m mountReporter) ID() string {
+ if len(m.Repositories) > 0 {
+ return m.Repositories[0]
+ }
+ return m.Id
+}
diff --git a/cmd/podman/images/prune.go b/cmd/podman/images/prune.go
index 002453907..8dc203ead 100644
--- a/cmd/podman/images/prune.go
+++ b/cmd/podman/images/prune.go
@@ -6,10 +6,10 @@ import (
"os"
"strings"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/cmd/podman/utils"
- "github.com/containers/libpod/v2/cmd/podman/validate"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/utils"
+ "github.com/containers/podman/v2/cmd/podman/validate"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/pull.go b/cmd/podman/images/pull.go
index 83bb186df..4deaecbf5 100644
--- a/cmd/podman/images/pull.go
+++ b/cmd/podman/images/pull.go
@@ -6,9 +6,9 @@ import (
"github.com/containers/common/pkg/auth"
"github.com/containers/image/v5/types"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
- "github.com/containers/libpod/v2/pkg/util"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -82,6 +82,7 @@ func pullFlags(flags *pflag.FlagSet) {
flags.StringVar(&pullOptions.CredentialsCLI, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
flags.StringVar(&pullOptions.OverrideArch, "override-arch", "", "Use `ARCH` instead of the architecture of the machine for choosing images")
flags.StringVar(&pullOptions.OverrideOS, "override-os", "", "Use `OS` instead of the running OS for choosing images")
+ flags.Bool("disable-content-trust", false, "This is a Docker specific option and is a NOOP")
flags.BoolVarP(&pullOptions.Quiet, "quiet", "q", false, "Suppress output information when pulling images")
flags.StringVar(&pullOptions.SignaturePolicy, "signature-policy", "", "`Pathname` of signature policy file (not usually used)")
flags.BoolVar(&pullOptions.TLSVerifyCLI, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries")
diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go
index 4eeed13d4..2943cccc9 100644
--- a/cmd/podman/images/push.go
+++ b/cmd/podman/images/push.go
@@ -5,9 +5,9 @@ import (
"github.com/containers/common/pkg/auth"
"github.com/containers/image/v5/types"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
- "github.com/containers/libpod/v2/pkg/util"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -79,6 +79,7 @@ func pushFlags(flags *pflag.FlagSet) {
flags.BoolVar(&pushOptions.Compress, "compress", false, "Compress tarball image layers when pushing to a directory using the 'dir' transport. (default is same compression type as source)")
flags.StringVar(&pushOptions.CredentialsCLI, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
flags.StringVar(&pushOptions.DigestFile, "digestfile", "", "Write the digest of the pushed image to the specified file")
+ flags.Bool("disable-content-trust", false, "This is a Docker specific option and is a NOOP")
flags.StringVarP(&pushOptions.Format, "format", "f", "", "Manifest type (oci, v2s1, or v2s2) to use when pushing an image using the 'dir' transport (default is manifest type of source)")
flags.BoolVarP(&pushOptions.Quiet, "quiet", "q", false, "Suppress output information when pushing images")
flags.BoolVar(&pushOptions.RemoveSignatures, "remove-signatures", false, "Discard any pre-existing signatures in the image")
diff --git a/cmd/podman/images/rm.go b/cmd/podman/images/rm.go
index c14c256fc..f6e52a49e 100644
--- a/cmd/podman/images/rm.go
+++ b/cmd/podman/images/rm.go
@@ -3,9 +3,9 @@ package images
import (
"fmt"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
- "github.com/containers/libpod/v2/pkg/errorhandling"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/errorhandling"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
diff --git a/cmd/podman/images/rmi.go b/cmd/podman/images/rmi.go
index 8e70906ce..520847890 100644
--- a/cmd/podman/images/rmi.go
+++ b/cmd/podman/images/rmi.go
@@ -3,8 +3,8 @@ package images
import (
"strings"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go
index 097cb3a40..024045b9d 100644
--- a/cmd/podman/images/save.go
+++ b/cmd/podman/images/save.go
@@ -5,12 +5,12 @@ import (
"os"
"strings"
- "github.com/containers/libpod/v2/libpod/define"
+ "github.com/containers/podman/v2/libpod/define"
- "github.com/containers/libpod/v2/cmd/podman/parse"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
- "github.com/containers/libpod/v2/pkg/util"
+ "github.com/containers/podman/v2/cmd/podman/parse"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go
index f1a2cda96..c7f16a838 100644
--- a/cmd/podman/images/search.go
+++ b/cmd/podman/images/search.go
@@ -8,9 +8,9 @@ import (
"github.com/containers/buildah/pkg/formats"
"github.com/containers/common/pkg/auth"
"github.com/containers/image/v5/types"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
- "github.com/containers/libpod/v2/pkg/util/camelcase"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/util/camelcase"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
diff --git a/cmd/podman/images/sign.go b/cmd/podman/images/sign.go
index 9115342ed..e331a64df 100644
--- a/cmd/podman/images/sign.go
+++ b/cmd/podman/images/sign.go
@@ -3,8 +3,8 @@ package images
import (
"os"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/tag.go b/cmd/podman/images/tag.go
index 1bb956288..be7f84588 100644
--- a/cmd/podman/images/tag.go
+++ b/cmd/podman/images/tag.go
@@ -1,8 +1,8 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/tree.go b/cmd/podman/images/tree.go
index f229cfa29..0b79c2a4b 100644
--- a/cmd/podman/images/tree.go
+++ b/cmd/podman/images/tree.go
@@ -3,8 +3,8 @@ package images
import (
"fmt"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/trust.go b/cmd/podman/images/trust.go
index 9fc8c1f07..842540110 100644
--- a/cmd/podman/images/trust.go
+++ b/cmd/podman/images/trust.go
@@ -1,9 +1,9 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/cmd/podman/validate"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/validate"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/trust_set.go b/cmd/podman/images/trust_set.go
index 71b77f961..878ffeea6 100644
--- a/cmd/podman/images/trust_set.go
+++ b/cmd/podman/images/trust_set.go
@@ -1,10 +1,10 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/libpod/image"
- "github.com/containers/libpod/v2/pkg/domain/entities"
- "github.com/containers/libpod/v2/pkg/util"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/libpod/image"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/trust_show.go b/cmd/podman/images/trust_show.go
index 79a583caa..d968f6d80 100644
--- a/cmd/podman/images/trust_show.go
+++ b/cmd/podman/images/trust_show.go
@@ -6,8 +6,8 @@ import (
"text/tabwriter"
"text/template"
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/images/unmount.go b/cmd/podman/images/unmount.go
new file mode 100644
index 000000000..f7f6cf8e5
--- /dev/null
+++ b/cmd/podman/images/unmount.go
@@ -0,0 +1,71 @@
+package images
+
+import (
+ "fmt"
+
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/utils"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+ "github.com/spf13/pflag"
+)
+
+var (
+ description = `Image storage increments a mount counter each time an image is mounted.
+
+ When an image is unmounted, the mount counter is decremented. The image's root filesystem is physically unmounted only when the mount counter reaches zero indicating no other processes are using the mount.
+
+ An unmount can be forced with the --force flag.
+`
+ unmountCommand = &cobra.Command{
+ Use: "unmount [flags] IMAGE [IMAGE...]",
+ Aliases: []string{"umount"},
+ Short: "Unmount an image's root filesystem",
+ Long: description,
+ RunE: unmount,
+ Example: `podman unmount imgID
+ podman unmount imgID1 imgID2 imgID3
+ podman unmount --all`,
+ }
+)
+
+var (
+ unmountOpts entities.ImageUnmountOptions
+)
+
+func unmountFlags(flags *pflag.FlagSet) {
+ flags.BoolVarP(&unmountOpts.All, "all", "a", false, "Unmount all of the currently mounted images")
+ flags.BoolVarP(&unmountOpts.Force, "force", "f", false, "Force the complete unmount of the specified mounted images")
+}
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Parent: imageCmd,
+ Command: unmountCommand,
+ })
+ unmountFlags(unmountCommand.Flags())
+}
+
+func unmount(cmd *cobra.Command, args []string) error {
+ var errs utils.OutputErrors
+ if len(args) < 1 && !unmountOpts.All {
+ return errors.New("image name or ID must be specified")
+ }
+ if len(args) > 0 && unmountOpts.All {
+ return errors.New("when using the --all switch, you may not pass any image names or IDs")
+ }
+ reports, err := registry.ImageEngine().Unmount(registry.GetContext(), args, unmountOpts)
+ if err != nil {
+ return err
+ }
+ for _, r := range reports {
+ if r.Err == nil {
+ fmt.Println(r.Id)
+ } else {
+ errs = append(errs, r.Err)
+ }
+ }
+ return errs.PrintErrors()
+}
diff --git a/cmd/podman/images/untag.go b/cmd/podman/images/untag.go
index 39804b2bc..da749c8a5 100644
--- a/cmd/podman/images/untag.go
+++ b/cmd/podman/images/untag.go
@@ -1,8 +1,8 @@
package images
import (
- "github.com/containers/libpod/v2/cmd/podman/registry"
- "github.com/containers/libpod/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
"github.com/spf13/cobra"
)