Podman Volumes

Volumes are file objects that podman(1) creates for a container. While they are written to the host file system, users should only interface with them as a volume name.

Compare to Bind Mounts.


Creating Volumes

To create a new volume, try:

podman volume create my-vol

A container can be created with an existing volume mounted into it.

podman run --interactive --tty --rm --name my-alpine \
  --mount src=my-vol,dst=/app \
  alpine:latest

A container can also be created with a new volume.

podman run --detach --name=my-nginx \
  --mount src=nginx-vol,dst=/usr/share/nginx/html \
  nginx:latest

The volume is implicitly created and the contents of the destination directory are written into the newly-initialized volume.

These volumes are generally written to ~/.local/share/containers/storage/volumes.


Destroying Volumes

After a container is stopped and destroyed, any volumes used will persist. This may or may not be desirable.

To list all volumes, try:

podman volume ls

To delete a volume, try:

podman volume rm my-vol


CategoryRicottone

Podman/Volumes (last edited 2023-04-06 14:10:49 by DominicRicottone)