Skip to content

container volume

Prayag edited this page May 9, 2023 · 6 revisions

Podman uses the following types of volumes and bind mounts to persist data.

  • Anonymous volumes: If we restart our container, the data will be visible, but not after we remove the container. Also, it’s not accessible by other containers.

  • Named volumes: Named volumes can persist data after we restart or remove a container. Also, it’s accessible by other containers.

  • Bind mounts: Named volumes and bind mounts are the same, except the named volumes can be found under a specific host directory, and bind mounts can be any host directory.

show volumes

podman volume ls

podman-compose YAML

$ cat podman-compose.yml 
version: '3.3'

services:
  volumes:
    cockroach_data:

  local_cockroach:
    image: cockroachdb/cockroach:latest
    volumes:
      - cockroach_data:/cockroach-cockroach-data
    command: start-single-node --insecure
    ports:
      - "26257:26257"
      - "8080:8080"
podman volume inspect forecasting-service_cassandra_data
[
     {
          "Name": "forecasting-service_ cockroach_data",
          "Driver": "local",
          "Mountpoint": "/var/lib/containers/storage/volumes/forecasting-service_cockroach_data/_data",
          "CreatedAt": "2022-04-15T21:52:47.147862108-07:00",
          "Labels": {
               "com.docker.compose.project": "forecasting-service",
               "io.podman.compose.project": "forecasting-service"
          },
          "Scope": "local",
          "Options": {},
          "MountCount": 0,
          "NeedsCopyUp": true
     }
]
podman system df -v --format '{{ .BuildCache | json }}'

Remove volumes

docker volume rm $(docker volume ls -q --filter dangling=true)

Clone this wiki locally