-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add podman volume mount support #13318
Merged
+252
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package volumes | ||
|
||
import ( | ||
"fmt" | ||
|
||
"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/spf13/cobra" | ||
) | ||
|
||
var ( | ||
volumeMountDescription = `Mount a volume and return the mountpoint` | ||
volumeMountCommand = &cobra.Command{ | ||
Annotations: map[string]string{ | ||
registry.UnshareNSRequired: "", | ||
registry.ParentNSRequired: "", | ||
registry.EngineMode: registry.ABIMode, | ||
}, | ||
Use: "mount NAME", | ||
Short: "Mount volume", | ||
Long: volumeMountDescription, | ||
RunE: volumeMount, | ||
Example: `podman volume mount myvol`, | ||
Args: cobra.ExactArgs(1), | ||
ValidArgsFunction: common.AutocompleteVolumes, | ||
} | ||
) | ||
|
||
func init() { | ||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Command: volumeMountCommand, | ||
Parent: volumeCmd, | ||
}) | ||
} | ||
|
||
func volumeMount(cmd *cobra.Command, args []string) error { | ||
var errs utils.OutputErrors | ||
reports, err := registry.ContainerEngine().VolumeMount(registry.GetContext(), args) | ||
if err != nil { | ||
return err | ||
} | ||
for _, r := range reports { | ||
if r.Err == nil { | ||
fmt.Println(r.Path) | ||
continue | ||
} | ||
errs = append(errs, r.Err) | ||
} | ||
return errs.PrintErrors() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package volumes | ||
|
||
import ( | ||
"fmt" | ||
|
||
"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/spf13/cobra" | ||
) | ||
|
||
var ( | ||
volumeUnmountDescription = `Unmount a volume` | ||
volumeUnmountCommand = &cobra.Command{ | ||
Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, | ||
Use: "unmount NAME", | ||
Short: "Unmount volume", | ||
Long: volumeUnmountDescription, | ||
RunE: volumeUnmount, | ||
Example: `podman volume unmount myvol`, | ||
Args: cobra.ExactArgs(1), | ||
ValidArgsFunction: common.AutocompleteVolumes, | ||
} | ||
) | ||
|
||
func init() { | ||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Command: volumeUnmountCommand, | ||
Parent: volumeCmd, | ||
}) | ||
} | ||
|
||
func volumeUnmount(cmd *cobra.Command, args []string) error { | ||
var errs utils.OutputErrors | ||
reports, err := registry.ContainerEngine().VolumeUnmount(registry.GetContext(), args) | ||
if err != nil { | ||
return err | ||
} | ||
for _, r := range reports { | ||
var errs utils.OutputErrors | ||
if r.Err == nil { | ||
fmt.Println(r.Id) | ||
} else { | ||
errs = append(errs, r.Err) | ||
} | ||
} | ||
return errs.PrintErrors() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
% podman-volume-mount(1) | ||
|
||
## NAME | ||
podman\-volume\-mount - Mount a volume filesystem | ||
|
||
## SYNOPSIS | ||
**podman volume mount** [*volume* ...] | ||
|
||
## DESCRIPTION | ||
Mounts the specified volumes' file system in a location which can be | ||
accessed from the host, and returns its location. | ||
|
||
Rootless mode only supports mounting file volumes, unless you enter the user namespace | ||
via the `podman unshare` command. All other volume types will fail to mount. | ||
|
||
## RETURN VALUE | ||
The location of the mounted file system. On error an empty string and errno is | ||
returned. | ||
|
||
## EXAMPLE | ||
|
||
``` | ||
podman volume mount foo | ||
/home/dwalsh/.local/share/containers/storage/volumes/foo/_data | ||
``` | ||
|
||
## SEE ALSO | ||
**[podman(1)](podman.1.md)**, **[podman-volume(1)](podman-volume.1.md)**, **[podman-volume-unmount(1)](podman-volume-unmount.1.md)**, **[podman-unshare(1)](podman-unshare.1.md)**, **mount(8)** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
% podman-volume-unmount(1) | ||
|
||
## NAME | ||
podman\-volume\-unmount - Unmount a volume | ||
|
||
## SYNOPSIS | ||
**podman volume unmount** *volume* [...] | ||
|
||
**podman volume umount** *volume* [...] | ||
|
||
## DESCRIPTION | ||
Unmounts the specified volume, if there are no other containers | ||
using it. | ||
|
||
Volume storage increments a mount counter each time a volume is mounted. | ||
When a volume is unmounted, the mount counter is decremented, and the | ||
volume's filesystem is physically unmounted only when the mount | ||
counter reaches zero indicating no other processes are using the mount. | ||
|
||
## EXAMPLE | ||
|
||
podman volume unmount volumeID | ||
|
||
podman volume unmount volumeID1 volumeID2 volumeID3 | ||
|
||
## SEE ALSO | ||
**[podman(1)](podman.1.md)**, **[podman-volume(1)](podman-volume.1.md)**, **[podman-volume-mount(1)](podman-volume-mount.1.md)** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package libpod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test doesn't really do anything when rootless. Why not just
skip_if_rootless
?