Podman - hpaluch/hpaluch.github.io GitHub Wiki

Podman notes

Note: for quick Podman tutorial please look at MicroOS.

State DB

Unfortunately Podman stores configuration data in binary database (each major version using different backend!):

  1. Podman 4 (Podman 4.3.1, bbolt 1.3.6 on Debian 12) uses "Ben Johnson's Bolt key/value store" bolt_state.db. Example pathname: $HOME/.local/share/containers/storage/libpod/bolt_state.db

  2. Podman 5 (Podman 5.5.2, bbolt 1.40, sqlite3 1.14.28 on Fedora 42) uses SQLite db.sql. Example pathname $HOME/.local/share/containers/storage/db.sql. However Podman 5 is able to also open existing Bolt DB files.

Detail on BBolt (Podman 4)

Which is so called "Ben Johnson's Bolt key/value store" used by etcd. Official home is on: https://github.com/etcd-io/bbolt

To parse this database we need to build bbolt utility written in Go. This did the trick under Fedora 42:

# actually just installing Go should be enough:
sudo dnf install golang-etcd-bbolt-devel
go install go.etcd.io/bbolt@latest
go run go.etcd.io/bbolt/cmd/bbolt@latest

To simplify typing I copied bbolt from this cache directory:

$ find ~/.cache/go-build/ -type f -name bbolt

~/.cache/go-build/5c/5c43fa9ed96df4aef336e4649d3b4214467aef0d93d77ef0d1317125a9f4e01d-d/bbolt

To my ~/bin.

I also copied bolt_state.db to same directory to save typing lot of data:

$ find ~/.local -name 'bolt_state.db'
~/.local/share/containers/storage/libpod/bolt_state.db

Note: I actually transfered bbolt to Debian 12 machine where is one podman container named deb-mm1 created with: mmdebstrap unstable | podman import - debian-unstable from https://wiki.debian.org/Podman

Now few basic commands from: https://github.com/etcd-io/bbolt/tree/main/cmd/bbolt

$ ./bbolt pages bolt_state.db 

ID       TYPE       ITEMS  OVRFLW
======== ========== ====== ======
0        meta       0            
1        meta       0            
2        leaf       1            
3        leaf       14           
4        freelist   7            
5        free                    
6        leaf       3      3     
10       free                    
11       free                    
12       free                    
13       free                    
14       free                    
15       free                    

./bbolt page bolt_state.db 2

Page ID:    2              
Page Type:  leaf                      
Total Size: 4096 bytes       
Overflow pages: 0              
Item Count: 1                
                                         
"918e786c4bd794fcb3495e348e2d1c4c936dd68d7589e24840a916655d76211e": <pgid=6,seq=0>

./bbolt page bolt_state.db 3

Page ID:    3
Page Type:  leaf
Total Size: 4096 bytes
Overflow pages: 0
Item Count: 14

"all-ctrs": <pgid=0,seq=0>
"allPods": <pgid=0,seq=0>
"allVolumes": <pgid=0,seq=0>
"ctr": <pgid=2,seq=0>
"exec": <pgid=0,seq=0>
"exit-code": <pgid=0,seq=0>
"exit-code-time-stamp": <pgid=0,seq=0>
"id-registry": <pgid=0,seq=0>
"name-registry": <pgid=0,seq=0>
"ns-registry": <pgid=0,seq=0>
"pod": <pgid=0,seq=0>
"runtime-config": <pgid=0,seq=0>
"vol": <pgid=0,seq=0>
"volume-ctrs": <pgid=0,seq=0>

./bbolt page bolt_state.db 6
Page ID:    6
Page Type:  leaf
Total Size: 16384 bytes
Overflow pages: 3
Item Count: 3

"config": {"spec":{"ociVersion":"1.0.2-dev ...
"dependencies": <pgid=0,seq=0> ...
"state": {"state":6,"configPath":"/home/lx ...

$ ./bbolt page-item bolt_state.db 6 0  # getting just first item "config: ..." 0-based index

Or using buckets, but they are weird:


$ ./bbolt buckets bolt_state.db 

all-ctrs
allPods
allVolumes
ctr
exec
exit-code
exit-code-time-stamp
id-registry
name-registry
ns-registry
pod
runtime-config
vol
volume-ctrs

$ ./bbolt keys bolt_state.db ctr

918e786c4bd794fcb3495e348e2d1c4c936dd68d7589e24840a916655d76211e

NOTE: matches:

$ podman ps -a
CONTAINER ID  IMAGE                             COMMAND     CREATED            STATUS                     PORTS       NAMES
918e786c4bd7  localhost/debian-unstable:latest  /bin/sh     About an hour ago  Exited (0) 45 minutes ago              deb-mm1

But now it is tricky, because ctr contains sub-bucket:

# wrong query:

$ ./bbolt get bolt_state.db ctr 918e786c4bd794fcb3495e348e2d1c4c936dd68d7589e24840a916655d76211e
Error key not found for key: "918e786c4bd794fcb3495e348e2d1c4c936dd68d7589e24840a916655d76211e" hex: "39313865373836633462643739346663623334393565333438653264316334633933366464363864373538396532343834306139313636353564373632313165"

# proper query:

./bbolt keys bolt_state.db ctr 918e786c4bd794fcb3495e348e2d1c4c936dd68d7589e24840a916655d76211e

config
dependencies
state

./bbolt get bolt_state.db ctr 918e786c4bd794fcb3495e348e2d1c4c936dd68d7589e24840a916655d76211e config | jq

{
  "spec": {
    "ociVersion": "1.0.2-dev",
    "process": {
      "terminal": true,
      "user": {
        "uid": 0,
        "gid": 0
...

Or use inspect, but not much useful:

./bbolt inspect bolt_state.db
{
    "name": "root",
    "keyN": 0,
    "buckets": [
        {
            "name": "all-ctrs",
            "keyN": 1
        },
        {
            "name": "allPods",
            "keyN": 0
        },
        {
            "name": "allVolumes",
            "keyN": 0
        },
        {
            "name": "ctr",
            "keyN": 0,
            "buckets": [
                {
                    "name": "918e786c4bd794fcb3495e348e2d1c4c936dd68d7589e24840a916655d76211e",
                    "keyN": 2,
                    "buckets": [
                        {
                            "name": "dependencies",
                            "keyN": 0
                        }
                    ]
                }
            ]
        },
        {
            "name": "exec",
            "keyN": 0
        },
        {
            "name": "exit-code",
            "keyN": 1
        },
        {
            "name": "exit-code-time-stamp",
            "keyN": 1
        },
        {
            "name": "id-registry",
            "keyN": 1
        },
        {
            "name": "name-registry",
            "keyN": 1
        },
        {
            "name": "ns-registry",
            "keyN": 0
        },
        {
            "name": "pod",
            "keyN": 0
        },
        {
            "name": "runtime-config",
            "keyN": 7
        },
        {
            "name": "vol",
            "keyN": 0
        },
        {
            "name": "volume-ctrs",
            "keyN": 0
        }
    ]
}

But there is no edit command, aargh...