aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2022-04-11 20:59:31 -0500
committerBrent Baude <bbaude@redhat.com>2022-04-14 13:06:05 -0500
commit900739d134564f48bd91a159a25fac52b608bbf4 (patch)
tree87b6cb19c7324f666d44e0e65d83ff5e719bca43
parent53b984f20fef3a66269029f10c6cd16d7b80fd4e (diff)
downloadpodman-900739d134564f48bd91a159a25fac52b608bbf4.tar.gz
podman-900739d134564f48bd91a159a25fac52b608bbf4.tar.bz2
podman-900739d134564f48bd91a159a25fac52b608bbf4.zip
Add container.conf default volume to init
containers.conf now has a default volumes field for podman machine. this pr inserts those values as the default volumes in init. Signed-off-by: Brent Baude <bbaude@redhat.com> [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
-rw-r--r--cmd/podman/machine/init.go10
-rw-r--r--docs/source/markdown/podman-machine-init.1.md3
2 files changed, 10 insertions, 3 deletions
diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go
index 518e7490f..2d0afbf05 100644
--- a/cmd/podman/machine/init.go
+++ b/cmd/podman/machine/init.go
@@ -5,6 +5,7 @@ package machine
import (
"fmt"
+ "os"
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v4/cmd/podman/registry"
@@ -94,7 +95,7 @@ func init() {
_ = initCmd.RegisterFlagCompletionFunc(ImagePathFlagName, completion.AutocompleteDefault)
VolumeFlagName := "volume"
- flags.StringArrayVarP(&initOpts.Volumes, VolumeFlagName, "v", []string{}, "Volumes to mount, source:target")
+ flags.StringArrayVarP(&initOpts.Volumes, VolumeFlagName, "v", cfg.Machine.Volumes, "Volumes to mount, source:target")
_ = initCmd.RegisterFlagCompletionFunc(VolumeFlagName, completion.AutocompleteDefault)
VolumeDriverFlagName := "volume-driver"
@@ -112,9 +113,10 @@ func init() {
// TODO should we allow for a users to append to the qemu cmdline?
func initMachine(cmd *cobra.Command, args []string) error {
var (
- vm machine.VM
err error
+ vm machine.VM
)
+
provider := getSystemDefaultProvider()
initOpts.Name = defaultMachineName
if len(args) > 0 {
@@ -126,7 +128,9 @@ func initMachine(cmd *cobra.Command, args []string) error {
if _, err := provider.LoadVMByName(initOpts.Name); err == nil {
return errors.Wrap(machine.ErrVMAlreadyExists, initOpts.Name)
}
-
+ for idx, vol := range initOpts.Volumes {
+ initOpts.Volumes[idx] = os.ExpandEnv(vol)
+ }
vm, err = provider.NewMachine(initOpts)
if err != nil {
return err
diff --git a/docs/source/markdown/podman-machine-init.1.md b/docs/source/markdown/podman-machine-init.1.md
index ac258eaae..33947bbba 100644
--- a/docs/source/markdown/podman-machine-init.1.md
+++ b/docs/source/markdown/podman-machine-init.1.md
@@ -83,6 +83,9 @@ Podman mounts _host-dir_ in the host to _machine-dir_ in the Podman machine.
The root filesystem is mounted read-only in the default operating system,
so mounts must be created under the /mnt directory.
+Default volume mounts are defined in *containers.conf*. Unless changed, the default values
+is `$HOME:$HOME`.
+
#### **--volume-driver**
Driver to use for mounting volumes from the host, such as `virtfs`.