summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/create.go4
-rw-r--r--cmd/podman/common/create_opts.go10
-rw-r--r--cmd/podman/images/list.go6
-rw-r--r--cmd/podman/machine/inspect.go90
4 files changed, 103 insertions, 7 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index 4c58fdc57..62c9f4c9a 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -606,6 +606,10 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
)
_ = cmd.RegisterFlagCompletionFunc(chrootDirsFlagName, completion.AutocompleteDefault)
+ passwdEntryName := "passwd-entry"
+ createFlags.StringVar(&cf.PasswdEntry, passwdEntryName, "", "Entry to write to /etc/passwd")
+ _ = cmd.RegisterFlagCompletionFunc(passwdEntryName, completion.AutocompleteNone)
+
if registry.IsRemote() {
_ = createFlags.MarkHidden("env-host")
_ = createFlags.MarkHidden("http-proxy")
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index ad6b3870a..7b7626040 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -164,8 +164,13 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
}
}
- // netMode
- nsmode, networks, netOpts, err := specgen.ParseNetworkFlag([]string{string(cc.HostConfig.NetworkMode)})
+ // special case for NetworkMode, the podman default is slirp4netns for
+ // rootless but for better docker compat we want bridge.
+ netmode := string(cc.HostConfig.NetworkMode)
+ if netmode == "" || netmode == "default" {
+ netmode = "bridge"
+ }
+ nsmode, networks, netOpts, err := specgen.ParseNetworkFlag([]string{netmode})
if err != nil {
return nil, nil, err
}
@@ -181,6 +186,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
Network: nsmode,
PublishPorts: specPorts,
NetworkOptions: netOpts,
+ NoHosts: rtc.Containers.NoHosts,
}
// network names
diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go
index 10a2a4f87..9bddf1cff 100644
--- a/cmd/podman/images/list.go
+++ b/cmd/podman/images/list.go
@@ -87,7 +87,6 @@ func imageListFlagSet(cmd *cobra.Command) {
flags := cmd.Flags()
flags.BoolVarP(&listOptions.All, "all", "a", false, "Show all images (default hides intermediate images)")
- flags.BoolVarP(&listOptions.Size, "size", "", true, "Compute the size of each image")
filterFlagName := "filter"
flags.StringSliceVarP(&listOptions.Filter, filterFlagName, "f", []string{}, "Filter output based on conditions provided (default [])")
@@ -321,10 +320,7 @@ func lsFormatFromFlags(flags listFlagType) string {
row = append(row, "{{.Digest}}")
}
- row = append(row, "{{.ID}}", "{{.Created}}")
- if listOptions.Size {
- row = append(row, "{{.Size}}")
- }
+ row = append(row, "{{.ID}}", "{{.Created}}", "{{.Size}}")
if flags.history {
row = append(row, "{{if .History}}{{.History}}{{else}}<none>{{end}}")
diff --git a/cmd/podman/machine/inspect.go b/cmd/podman/machine/inspect.go
new file mode 100644
index 000000000..d43cabf6b
--- /dev/null
+++ b/cmd/podman/machine/inspect.go
@@ -0,0 +1,90 @@
+//go:build amd64 || arm64
+// +build amd64 arm64
+
+package machine
+
+import (
+ "encoding/json"
+ "os"
+
+ "github.com/containers/podman/v4/cmd/podman/common"
+ "github.com/containers/podman/v4/cmd/podman/registry"
+ "github.com/containers/podman/v4/cmd/podman/utils"
+ "github.com/containers/podman/v4/libpod/define"
+ "github.com/containers/podman/v4/pkg/machine"
+ "github.com/sirupsen/logrus"
+ "github.com/spf13/cobra"
+)
+
+var (
+ inspectCmd = &cobra.Command{
+ Use: "inspect [options] [MACHINE...]",
+ Short: "Inspect an existing machine",
+ Long: "Provide details on a managed virtual machine",
+ RunE: inspect,
+ Example: `podman machine inspect myvm`,
+ ValidArgsFunction: autocompleteMachine,
+ }
+ inspectFlag = inspectFlagType{}
+)
+
+type inspectFlagType struct {
+ format string
+}
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Command: inspectCmd,
+ Parent: machineCmd,
+ })
+
+ flags := inspectCmd.Flags()
+ formatFlagName := "format"
+ flags.StringVar(&inspectFlag.format, formatFlagName, "", "Format volume output using JSON or a Go template")
+ _ = inspectCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(machine.InspectInfo{}))
+}
+
+func inspect(cmd *cobra.Command, args []string) error {
+ var (
+ errs utils.OutputErrors
+ )
+ if len(args) < 1 {
+ args = append(args, defaultMachineName)
+ }
+ vms := make([]machine.InspectInfo, 0, len(args))
+ provider := getSystemDefaultProvider()
+ for _, vmName := range args {
+ vm, err := provider.LoadVMByName(vmName)
+ if err != nil {
+ errs = append(errs, err)
+ continue
+ }
+ state, err := vm.State()
+ if err != nil {
+ errs = append(errs, err)
+ continue
+ }
+ ii := machine.InspectInfo{
+ State: state,
+ VM: vm,
+ }
+ vms = append(vms, ii)
+ }
+ if len(inspectFlag.format) > 0 {
+ // need jhonce to work his template magic
+ return define.ErrNotImplemented
+ }
+ if err := printJSON(vms); err != nil {
+ logrus.Error(err)
+ }
+ return errs.PrintErrors()
+}
+
+func printJSON(data []machine.InspectInfo) error {
+ enc := json.NewEncoder(os.Stdout)
+ // by default, json marshallers will force utf=8 from
+ // a string. this breaks healthchecks that use <,>, &&.
+ enc.SetEscapeHTML(false)
+ enc.SetIndent("", " ")
+ return enc.Encode(data)
+}