summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/completion.go10
-rw-r--r--cmd/podman/common/create.go7
-rw-r--r--cmd/podman/common/volumes.go2
-rw-r--r--cmd/podman/containers/checkpoint.go10
-rw-r--r--cmd/podman/containers/prune.go4
-rw-r--r--cmd/podman/containers/ps.go5
-rw-r--r--cmd/podman/containers/rename.go55
-rw-r--r--cmd/podman/containers/restore.go11
-rw-r--r--cmd/podman/containers/stats.go27
-rw-r--r--cmd/podman/images/build.go12
-rw-r--r--cmd/podman/images/load.go23
-rw-r--r--cmd/podman/images/search.go47
-rw-r--r--cmd/podman/play/kube.go23
-rw-r--r--cmd/podman/pods/inspect.go5
-rw-r--r--cmd/podman/pods/prune.go2
-rw-r--r--cmd/podman/pods/ps.go5
-rw-r--r--cmd/podman/pods/rm.go4
-rw-r--r--cmd/podman/pods/stats.go11
-rw-r--r--cmd/podman/root.go2
-rw-r--r--cmd/podman/system/prune.go17
-rw-r--r--cmd/podman/system/service.go2
-rw-r--r--cmd/podman/utils/utils.go35
22 files changed, 234 insertions, 85 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index 83fe0723c..d01842998 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -982,9 +982,10 @@ func AutocompletePsFilters(cmd *cobra.Command, args []string, toComplete string)
return []string{define.HealthCheckHealthy,
define.HealthCheckUnhealthy}, cobra.ShellCompDirectiveNoFileComp
},
- "label=": nil,
- "exited=": nil,
- "until=": nil,
+ "network=": func(s string) ([]string, cobra.ShellCompDirective) { return getNetworks(cmd, s) },
+ "label=": nil,
+ "exited=": nil,
+ "until=": nil,
}
return completeKeyValues(toComplete, kv)
}
@@ -1004,7 +1005,8 @@ func AutocompletePodPsFilters(cmd *cobra.Command, args []string, toComplete stri
"ctr-status=": func(_ string) ([]string, cobra.ShellCompDirective) {
return containerStatuses, cobra.ShellCompDirectiveNoFileComp
},
- "label=": nil,
+ "network=": func(s string) ([]string, cobra.ShellCompDirective) { return getNetworks(cmd, s) },
+ "label=": nil,
}
return completeKeyValues(toComplete, kv)
}
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index bbd4f6bae..280175f95 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -1,7 +1,6 @@
package common
import (
- "fmt"
"os"
"github.com/containers/common/pkg/auth"
@@ -181,7 +180,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
createFlags.StringSliceVar(
&cf.Devices,
deviceFlagName, devices(),
- fmt.Sprintf("Add a host device to the container"),
+ "Add a host device to the container",
)
_ = cmd.RegisterFlagCompletionFunc(deviceFlagName, completion.AutocompleteDefault)
@@ -336,7 +335,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
createFlags.BoolVar(
&cf.HTTPProxy,
- "http-proxy", true,
+ "http-proxy", containerConfig.Containers.HTTPProxy,
"Set proxy environment variables in the container based on the host proxy vars",
)
@@ -359,7 +358,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
&cf.InitPath,
initPathFlagName, initPath(),
// Do not use the Value field for setting the default value to determine user input (i.e., non-empty string)
- fmt.Sprintf("Path to the container-init binary"),
+ "Path to the container-init binary",
)
_ = cmd.RegisterFlagCompletionFunc(initPathFlagName, completion.AutocompleteDefault)
diff --git a/cmd/podman/common/volumes.go b/cmd/podman/common/volumes.go
index dfbb7b1b2..a6e6faeca 100644
--- a/cmd/podman/common/volumes.go
+++ b/cmd/podman/common/volumes.go
@@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"
- "github.com/containers/buildah/pkg/parse"
+ "github.com/containers/common/pkg/parse"
"github.com/containers/podman/v2/pkg/specgen"
"github.com/containers/podman/v2/pkg/util"
spec "github.com/opencontainers/runtime-spec/specs-go"
diff --git a/cmd/podman/containers/checkpoint.go b/cmd/podman/containers/checkpoint.go
index b6dc21348..14abfd5a7 100644
--- a/cmd/podman/containers/checkpoint.go
+++ b/cmd/podman/containers/checkpoint.go
@@ -57,6 +57,10 @@ func init() {
_ = checkpointCommand.RegisterFlagCompletionFunc(exportFlagName, completion.AutocompleteDefault)
flags.BoolVar(&checkpointOptions.IgnoreRootFS, "ignore-rootfs", false, "Do not include root file-system changes when exporting")
+ flags.BoolVar(&checkpointOptions.IgnoreVolumes, "ignore-volumes", false, "Do not export volumes associated with container")
+ flags.BoolVarP(&checkpointOptions.PreCheckPoint, "pre-checkpoint", "P", false, "Dump container's memory information only, leave the container running")
+ flags.BoolVar(&checkpointOptions.WithPrevious, "with-previous", false, "Checkpoint container with pre-checkpoint images")
+
validate.AddLatestFlag(checkpointCommand, &checkpointOptions.Latest)
}
@@ -68,6 +72,12 @@ func checkpoint(cmd *cobra.Command, args []string) error {
if checkpointOptions.Export == "" && checkpointOptions.IgnoreRootFS {
return errors.Errorf("--ignore-rootfs can only be used with --export")
}
+ if checkpointOptions.Export == "" && checkpointOptions.IgnoreVolumes {
+ return errors.Errorf("--ignore-volumes can only be used with --export")
+ }
+ if checkpointOptions.WithPrevious && checkpointOptions.PreCheckPoint {
+ return errors.Errorf("--with-previous can not be used with --pre-checkpoint")
+ }
responses, err := registry.ContainerEngine().ContainerCheckpoint(context.Background(), args, checkpointOptions)
if err != nil {
return err
diff --git a/cmd/podman/containers/prune.go b/cmd/podman/containers/prune.go
index d3842778b..50731dd21 100644
--- a/cmd/podman/containers/prune.go
+++ b/cmd/podman/containers/prune.go
@@ -18,9 +18,9 @@ import (
)
var (
- pruneDescription = fmt.Sprintf(`podman container prune
+ pruneDescription = `podman container prune
- Removes all non running containers`)
+ Removes all non running containers`
pruneCommand = &cobra.Command{
Use: "prune [options]",
Short: "Remove all non running containers",
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 5d08e6163..d23771fc5 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -392,6 +392,11 @@ func (l psReporter) Names() string {
return l.ListContainer.Names[0]
}
+// Networks returns the container network names in string format
+func (l psReporter) Networks() string {
+ return strings.Join(l.ListContainer.Networks, ",")
+}
+
// Ports converts from Portmappings to the string form
// required by ps
func (l psReporter) Ports() string {
diff --git a/cmd/podman/containers/rename.go b/cmd/podman/containers/rename.go
new file mode 100644
index 000000000..b6c4f792c
--- /dev/null
+++ b/cmd/podman/containers/rename.go
@@ -0,0 +1,55 @@
+package containers
+
+import (
+ "github.com/containers/podman/v2/cmd/podman/common"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ renameDescription = "The podman rename command allows you to rename an existing container"
+ renameCommand = &cobra.Command{
+ Use: "rename CONTAINER NAME",
+ Short: "Rename an existing container",
+ Long: renameDescription,
+ RunE: rename,
+ Args: cobra.ExactArgs(2),
+ ValidArgsFunction: common.AutocompletePortCommand,
+ Example: "podman rename containerA newName",
+ }
+
+ containerRenameCommand = &cobra.Command{
+ Use: renameCommand.Use,
+ Short: renameCommand.Short,
+ Long: renameCommand.Long,
+ RunE: renameCommand.RunE,
+ Args: renameCommand.Args,
+ ValidArgsFunction: renameCommand.ValidArgsFunction,
+ Example: "podman container rename containerA newName",
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: renameCommand,
+ })
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerRenameCommand,
+ Parent: containerCmd,
+ })
+}
+
+func rename(cmd *cobra.Command, args []string) error {
+ if len(args) > 2 {
+ return errors.Errorf("must provide at least two arguments to rename")
+ }
+ renameOpts := entities.ContainerRenameOptions{
+ NewName: args[1],
+ }
+ return registry.ContainerEngine().ContainerRename(registry.GetContext(), args[0], renameOpts)
+}
diff --git a/cmd/podman/containers/restore.go b/cmd/podman/containers/restore.go
index 6a1d2b319..49c0be88e 100644
--- a/cmd/podman/containers/restore.go
+++ b/cmd/podman/containers/restore.go
@@ -59,9 +59,14 @@ func init() {
flags.StringVarP(&restoreOptions.Name, nameFlagName, "n", "", "Specify new name for container restored from exported checkpoint (only works with --import)")
_ = restoreCommand.RegisterFlagCompletionFunc(nameFlagName, completion.AutocompleteNone)
+ importPreviousFlagName := "import-previous"
+ flags.StringVar(&restoreOptions.ImportPrevious, importPreviousFlagName, "", "Restore from exported pre-checkpoint archive (tar.gz)")
+ _ = restoreCommand.RegisterFlagCompletionFunc(importPreviousFlagName, completion.AutocompleteDefault)
+
flags.BoolVar(&restoreOptions.IgnoreRootFS, "ignore-rootfs", false, "Do not apply root file-system changes when importing from exported checkpoint")
flags.BoolVar(&restoreOptions.IgnoreStaticIP, "ignore-static-ip", false, "Ignore IP address set via --static-ip")
flags.BoolVar(&restoreOptions.IgnoreStaticMAC, "ignore-static-mac", false, "Ignore MAC address set via --mac-address")
+ flags.BoolVar(&restoreOptions.IgnoreVolumes, "ignore-volumes", false, "Do not export volumes associated with container")
validate.AddLatestFlag(restoreCommand, &restoreOptions.Latest)
}
@@ -70,9 +75,15 @@ func restore(_ *cobra.Command, args []string) error {
if rootless.IsRootless() {
return errors.New("restoring a container requires root")
}
+ if restoreOptions.Import == "" && restoreOptions.ImportPrevious != "" {
+ return errors.Errorf("--import-previous can only be used with --import")
+ }
if restoreOptions.Import == "" && restoreOptions.IgnoreRootFS {
return errors.Errorf("--ignore-rootfs can only be used with --import")
}
+ if restoreOptions.Import == "" && restoreOptions.IgnoreVolumes {
+ return errors.Errorf("--ignore-volumes can only be used with --import")
+ }
if restoreOptions.Import == "" && restoreOptions.Name != "" {
return errors.Errorf("--name can only be used with --import")
}
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go
index ca5c0fdb8..1a436aaef 100644
--- a/cmd/podman/containers/stats.go
+++ b/cmd/podman/containers/stats.go
@@ -147,13 +147,14 @@ func stats(cmd *cobra.Command, args []string) error {
func outputStats(reports []define.ContainerStats) error {
headers := report.Headers(define.ContainerStats{}, map[string]string{
- "ID": "ID",
- "CPUPerc": "CPU %",
- "MemUsage": "MEM USAGE / LIMIT",
- "MemPerc": "MEM %",
- "NetIO": "NET IO",
- "BlockIO": "BLOCK IO",
- "PIDS": "PIDS",
+ "ID": "ID",
+ "CPUPerc": "CPU %",
+ "MemUsage": "MEM USAGE / LIMIT",
+ "MemUsageBytes": "MEM USAGE / LIMIT",
+ "MemPerc": "MEM %",
+ "NetIO": "NET IO",
+ "BlockIO": "BLOCK IO",
+ "PIDS": "PIDS",
})
if !statsOptions.NoReset {
tm.Clear()
@@ -222,10 +223,15 @@ func (s *containerStats) PIDS() string {
}
return fmt.Sprintf("%d", s.PIDs)
}
+
func (s *containerStats) MemUsage() string {
return combineHumanValues(s.ContainerStats.MemUsage, s.ContainerStats.MemLimit)
}
+func (s *containerStats) MemUsageBytes() string {
+ return combineBytesValues(s.ContainerStats.MemUsage, s.ContainerStats.MemLimit)
+}
+
func floatToPercentString(f float64) string {
strippedFloat, err := utils.RemoveScientificNotationFromFloat(f)
if err != nil || strippedFloat == 0 {
@@ -242,6 +248,13 @@ func combineHumanValues(a, b uint64) string {
return fmt.Sprintf("%s / %s", units.HumanSize(float64(a)), units.HumanSize(float64(b)))
}
+func combineBytesValues(a, b uint64) string {
+ if a == 0 && b == 0 {
+ return "-- / --"
+ }
+ return fmt.Sprintf("%s / %s", units.BytesSize(float64(a)), units.BytesSize(float64(b)))
+}
+
func outputJSON(stats []containerStats) error {
type jstat struct {
Id string `json:"id"` // nolint
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 3aca104e3..1029e03d1 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -135,6 +135,16 @@ func buildFlags(cmd *cobra.Command) {
logrus.Errorf("error setting up build flags: %v", err)
os.Exit(1)
}
+ // --http-proxy flag
+ // containers.conf defaults to true but we want to force false by default for remote, since settings do not apply
+ if registry.IsRemote() {
+ flag = fromAndBudFlags.Lookup("http-proxy")
+ buildOpts.HTTPProxy = false
+ if err := flag.Value.Set("false"); err != nil {
+ logrus.Errorf("unable to set --https-proxy to %v: %v", false, err)
+ }
+ flag.DefValue = "false"
+ }
flags.AddFlagSet(&fromAndBudFlags)
// Add the completion functions
fromAndBudFlagsCompletions := buildahCLI.GetFromAndBudFlagsCompletions()
@@ -394,7 +404,6 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
AddCapabilities: flags.CapAdd,
AdditionalTags: tags,
Annotations: flags.Annotation,
- Architecture: flags.Arch,
Args: args,
BlobDirectory: flags.BlobCache,
CNIConfigDir: flags.CNIConfigDir,
@@ -429,7 +438,6 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
Layers: flags.Layers,
NamespaceOptions: nsValues,
NoCache: flags.NoCache,
- OS: flags.OS,
Out: stdout,
Output: output,
OutputFormat: format,
diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go
index a24f46781..59fc6f54c 100644
--- a/cmd/podman/images/load.go
+++ b/cmd/podman/images/load.go
@@ -9,9 +9,8 @@ import (
"strings"
"github.com/containers/common/pkg/completion"
- "github.com/containers/image/v5/docker/reference"
- "github.com/containers/podman/v2/cmd/podman/parse"
"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/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
@@ -22,11 +21,11 @@ import (
var (
loadDescription = "Loads an image from a locally stored archive (tar file) into container storage."
loadCommand = &cobra.Command{
- Use: "load [options] [NAME[:TAG]]",
+ Use: "load [options]",
Short: "Load image(s) from a tar archive",
Long: loadDescription,
RunE: load,
- Args: cobra.MaximumNArgs(1),
+ Args: validate.NoArgs,
ValidArgsFunction: completion.AutocompleteNone,
}
@@ -71,22 +70,8 @@ func loadFlags(cmd *cobra.Command) {
}
func load(cmd *cobra.Command, args []string) error {
- if len(args) > 0 {
- ref, err := reference.Parse(args[0])
- if err != nil {
- return err
- }
- if t, ok := ref.(reference.Tagged); ok {
- loadOpts.Tag = t.Tag()
- } else {
- loadOpts.Tag = "latest"
- }
- if r, ok := ref.(reference.Named); ok {
- loadOpts.Name = r.Name()
- }
- }
if len(loadOpts.Input) > 0 {
- if err := parse.ValidateFileName(loadOpts.Input); err != nil {
+ if _, err := os.Stat(loadOpts.Input); err != nil {
return err
}
} else {
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go
index c2ef7d767..c8ea4b04a 100644
--- a/cmd/podman/images/search.go
+++ b/cmd/podman/images/search.go
@@ -26,6 +26,12 @@ type searchOptionsWrapper struct {
Format string // For go templating
}
+// listEntryTag is a utility structure used for json serialization.
+type listEntryTag struct {
+ Name string
+ Tags []string
+}
+
var (
searchOptions = searchOptionsWrapper{}
searchDescription = `Search registries for a given image. Can search all the default registries or a specific registry.
@@ -149,14 +155,13 @@ func imageSearch(cmd *cobra.Command, args []string) error {
if len(searchOptions.Filters) != 0 {
return errors.Errorf("filters are not applicable to list tags result")
}
+ if report.IsJSON(searchOptions.Format) {
+ listTagsEntries := buildListTagsJson(searchReport)
+ return printJson(listTagsEntries)
+ }
row = "{{.Name}}\t{{.Tag}}\n"
case report.IsJSON(searchOptions.Format):
- prettyJSON, err := json.MarshalIndent(searchReport, "", " ")
- if err != nil {
- return err
- }
- fmt.Println(string(prettyJSON))
- return nil
+ return printJson(searchReport)
case cmd.Flags().Changed("format"):
renderHeaders = parse.HasTable(searchOptions.Format)
row = report.NormalizeFormat(searchOptions.Format)
@@ -180,3 +185,33 @@ func imageSearch(cmd *cobra.Command, args []string) error {
return tmpl.Execute(w, searchReport)
}
+
+func printJson(v interface{}) error {
+ prettyJSON, err := json.MarshalIndent(v, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(prettyJSON))
+ return nil
+}
+
+func buildListTagsJson(searchReport []entities.ImageSearchReport) []listEntryTag {
+ entries := []listEntryTag{}
+
+ReportLoop:
+ for _, report := range searchReport {
+ for idx, entry := range entries {
+ if entry.Name == report.Name {
+ entries[idx].Tags = append(entries[idx].Tags, report.Tag)
+ continue ReportLoop
+ }
+ }
+ newElem := listEntryTag{
+ report.Name,
+ []string{report.Tag},
+ }
+
+ entries = append(entries, newElem)
+ }
+ return entries
+}
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index db7280b1d..4c44fa30f 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/podman/v2/cmd/podman/utils"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/util"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -126,28 +127,42 @@ func kube(cmd *cobra.Command, args []string) error {
for _, pod := range report.Pods {
for _, l := range pod.Logs {
- fmt.Fprintf(os.Stderr, l)
+ fmt.Fprint(os.Stderr, l)
}
}
+ ctrsFailed := 0
+
for _, pod := range report.Pods {
- fmt.Printf("Pod:\n")
+ fmt.Println("Pod:")
fmt.Println(pod.ID)
switch len(pod.Containers) {
case 0:
continue
case 1:
- fmt.Printf("Container:\n")
+ fmt.Println("Container:")
default:
- fmt.Printf("Containers:\n")
+ fmt.Println("Containers:")
}
for _, ctr := range pod.Containers {
fmt.Println(ctr)
}
+ ctrsFailed += len(pod.ContainerErrors)
+ // If We have errors, add a newline
+ if len(pod.ContainerErrors) > 0 {
+ fmt.Println()
+ }
+ for _, err := range pod.ContainerErrors {
+ fmt.Fprintln(os.Stderr, err)
+ }
// Empty line for space for next block
fmt.Println()
}
+ if ctrsFailed > 0 {
+ return errors.Errorf("failed to start %d containers", ctrsFailed)
+ }
+
return nil
}
diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go
index 091094ff6..e809be0c9 100644
--- a/cmd/podman/pods/inspect.go
+++ b/cmd/podman/pods/inspect.go
@@ -2,7 +2,6 @@ package pods
import (
"context"
- "fmt"
"os"
"text/tabwriter"
"text/template"
@@ -21,9 +20,9 @@ var (
)
var (
- inspectDescription = fmt.Sprintf(`Display the configuration for a pod by name or id
+ inspectDescription = `Display the configuration for a pod by name or id
- By default, this will render all results in a JSON array.`)
+ By default, this will render all results in a JSON array.`
inspectCmd = &cobra.Command{
Use: "inspect [options] POD [POD...]",
diff --git a/cmd/podman/pods/prune.go b/cmd/podman/pods/prune.go
index 965c36398..a040a21b6 100644
--- a/cmd/podman/pods/prune.go
+++ b/cmd/podman/pods/prune.go
@@ -20,7 +20,7 @@ var (
)
var (
- pruneDescription = fmt.Sprintf(`podman pod prune Removes all exited pods`)
+ pruneDescription = `podman pod prune Removes all exited pods`
pruneCommand = &cobra.Command{
Use: "prune [options]",
diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go
index 99d324411..a27ab4859 100644
--- a/cmd/podman/pods/ps.go
+++ b/cmd/podman/pods/ps.go
@@ -191,6 +191,11 @@ func (l ListPodReporter) Labels() map[string]string {
return l.ListPodsReport.Labels
}
+// Networks returns the infra container network names in string format
+func (l ListPodReporter) Networks() string {
+ return strings.Join(l.ListPodsReport.Networks, ",")
+}
+
// NumberOfContainers returns an int representation for
// the number of containers belonging to the pod
func (l ListPodReporter) NumberOfContainers() int {
diff --git a/cmd/podman/pods/rm.go b/cmd/podman/pods/rm.go
index ff238aa20..109f18b78 100644
--- a/cmd/podman/pods/rm.go
+++ b/cmd/podman/pods/rm.go
@@ -25,9 +25,9 @@ type podRmOptionsWrapper struct {
var (
rmOptions = podRmOptionsWrapper{}
- podRmDescription = fmt.Sprintf(`podman rm will remove one or more stopped pods and their containers from the host.
+ podRmDescription = `podman rm will remove one or more stopped pods and their containers from the host.
- The pod name or ID can be used. A pod with containers will not be removed without --force. If --force is specified, all containers will be stopped, then removed.`)
+ The pod name or ID can be used. A pod with containers will not be removed without --force. If --force is specified, all containers will be stopped, then removed.`
rmCommand = &cobra.Command{
Use: "rm [options] POD [POD...]",
Short: "Remove one or more pods",
diff --git a/cmd/podman/pods/stats.go b/cmd/podman/pods/stats.go
index 79e7cd8ed..5f79fa016 100644
--- a/cmd/podman/pods/stats.go
+++ b/cmd/podman/pods/stats.go
@@ -75,11 +75,12 @@ func stats(cmd *cobra.Command, args []string) error {
doJSON := report.IsJSON(row)
headers := report.Headers(entities.PodStatsReport{}, map[string]string{
- "CPU": "CPU %",
- "MemUsage": "MEM USAGE/ LIMIT",
- "MEM": "MEM %",
- "NET IO": "NET IO",
- "BlockIO": "BLOCK IO",
+ "CPU": "CPU %",
+ "MemUsage": "MEM USAGE/ LIMIT",
+ "MemUsageBytes": "MEM USAGE/ LIMIT",
+ "MEM": "MEM %",
+ "NET IO": "NET IO",
+ "BlockIO": "BLOCK IO",
})
for ; ; time.Sleep(time.Second) {
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 1f613a4c5..0ee530242 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -158,7 +158,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
// Prep the engines
if _, err := registry.NewImageEngine(cmd, args); err != nil {
- return err
+ return errors.Wrapf(err, "Cannot connect to the Podman socket, make sure there is a Podman REST API service running.")
}
if _, err := registry.NewContainerEngine(cmd, args); err != nil {
return err
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go
index 93b4a1157..5e96a654a 100644
--- a/cmd/podman/system/prune.go
+++ b/cmd/podman/system/prune.go
@@ -13,17 +13,18 @@ import (
"github.com/containers/podman/v2/cmd/podman/validate"
"github.com/containers/podman/v2/pkg/domain/entities"
dfilters "github.com/containers/podman/v2/pkg/domain/filters"
+ "github.com/docker/go-units"
"github.com/spf13/cobra"
)
var (
pruneOptions = entities.SystemPruneOptions{}
filters []string
- pruneDescription = fmt.Sprintf(`
+ pruneDescription = `
podman system prune
Remove unused data
-`)
+`
pruneCommand = &cobra.Command{
Use: "prune [options]",
@@ -90,7 +91,7 @@ Are you sure you want to continue? [y/N] `, volumeString)
return err
}
// Print container prune results
- err = utils.PrintContainerPruneResults(response.ContainerPruneReport, true)
+ err = utils.PrintContainerPruneResults(response.ContainerPruneReports, true)
if err != nil {
return err
}
@@ -101,11 +102,17 @@ Are you sure you want to continue? [y/N] `, volumeString)
}
// Print Volume prune results
if pruneOptions.Volume {
- err = utils.PrintVolumePruneResults(response.VolumePruneReport, true)
+ err = utils.PrintVolumePruneResults(response.VolumePruneReports, true)
if err != nil {
return err
}
}
// Print Images prune results
- return utils.PrintImagePruneResults(response.ImagePruneReport, true)
+ err = utils.PrintImagePruneResults(response.ImagePruneReports, true)
+ if err != nil {
+ return err
+ }
+
+ fmt.Printf("Total reclaimed space: %s\n", units.HumanSize((float64)(response.ReclaimedSpace)))
+ return nil
}
diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go
index f8bdbfa10..f5760e172 100644
--- a/cmd/podman/system/service.go
+++ b/cmd/podman/system/service.go
@@ -80,7 +80,7 @@ func service(cmd *cobra.Command, args []string) error {
}
// socket activation uses a unix:// socket in the shipped unit files but apiURI is coded as "" at this layer.
- if "unix" == uri.Scheme && !registry.IsRemote() {
+ if uri.Scheme == "unix" && !registry.IsRemote() {
if err := syscall.Unlink(uri.Path); err != nil && !os.IsNotExist(err) {
return err
}
diff --git a/cmd/podman/utils/utils.go b/cmd/podman/utils/utils.go
index 2ca2c4c92..f42243f69 100644
--- a/cmd/podman/utils/utils.go
+++ b/cmd/podman/utils/utils.go
@@ -5,6 +5,7 @@ import (
"os"
"github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/domain/entities/reports"
)
// IsDir returns true if the specified path refers to a directory.
@@ -41,21 +42,21 @@ func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport, heading bo
return errs.PrintErrors()
}
-func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneReport, heading bool) error {
+func PrintContainerPruneResults(containerPruneReports []*reports.PruneReport, heading bool) error {
var errs OutputErrors
- if heading && (len(containerPruneReport.ID) > 0 || len(containerPruneReport.Err) > 0) {
+ if heading && (len(containerPruneReports) > 0) {
fmt.Println("Deleted Containers")
}
- for k := range containerPruneReport.ID {
- fmt.Println(k)
- }
- for _, v := range containerPruneReport.Err {
- errs = append(errs, v)
+ for _, v := range containerPruneReports {
+ fmt.Println(v.Id)
+ if v.Err != nil {
+ errs = append(errs, v.Err)
+ }
}
return errs.PrintErrors()
}
-func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport, heading bool) error {
+func PrintVolumePruneResults(volumePruneReport []*reports.PruneReport, heading bool) error {
var errs OutputErrors
if heading && len(volumePruneReport) > 0 {
fmt.Println("Deleted Volumes")
@@ -70,18 +71,16 @@ func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport, he
return errs.PrintErrors()
}
-func PrintImagePruneResults(imagePruneReport *entities.ImagePruneReport, heading bool) error {
- if heading && (len(imagePruneReport.Report.Id) > 0 || len(imagePruneReport.Report.Err) > 0) {
+func PrintImagePruneResults(imagePruneReports []*reports.PruneReport, heading bool) error {
+ if heading {
fmt.Println("Deleted Images")
}
- for _, i := range imagePruneReport.Report.Id {
- fmt.Println(i)
- }
- for _, e := range imagePruneReport.Report.Err {
- fmt.Fprint(os.Stderr, e.Error()+"\n")
- }
- if imagePruneReport.Size > 0 {
- fmt.Fprintf(os.Stdout, "Size: %d\n", imagePruneReport.Size)
+ for _, r := range imagePruneReports {
+ fmt.Println(r.Id)
+ if r.Err != nil {
+ fmt.Fprint(os.Stderr, r.Err.Error()+"\n")
+ }
}
+
return nil
}