How to install apk packages to usb?

From the document it seems I need to use the -p option, but when I ran apk -p /mnt/mmcblk0p2/openwrt add python3 two errors raised:

ERROR: Unable to read database: No such file or directory
ERROR: Failed to open apk database: No such file or directory

Found a workaround:

root_dir=/mnt/mmcblk0p2/openwrt
ln -s /lib/apk ${root_dir}/lib/
ln -s /etc/apk ${root_dir}/etc/
apk -p $root_dir update
apk -p $root_dir add <package_name>

The problem is can't remember packages installed on usb separately.