How to list installed apk packages on Alpine Linux

What command do I need to run to list ALL installed packages on Alpine Linux? What I need is equivalent of apt list --installed that I used on a Debian Linux 11 but for Alpine Linux server running on EC2. Is it possible? How do I list and search packages on Alpine Linux server?

Try the apk command as follows to list all installed packages on your Alpine Linux server.

Listing all installed packages on Alpine Linux

The apk list command searches package indicies for packages matching the given patterns and prints any matching packages. Try passing the -I option:

apk list -I 
apk list -I | more

Want to list only nginx or php8 packages? Try using the grep command:

apk list -I | grep nginx

Here is what I see:

nginx-1.20.2-r1 x86_64 {nginx} (BSD-2-Clause) [installed]
nginx-openrc-1.20.2-r1 x86_64 {nginx} (BSD-2-Clause) [installed]
nginx-vim-1.20.2-r1 x86_64 {nginx} (BSD-2-Clause) [installed]
nginx-mod-http-brotli-1.20.2-r1 x86_64 {nginx} (BSD-2-Clause) [installed]

How to list and search packages on Alpine Linux Server

Another option: apk info command prints information known about the listed packages. For example:

apk info 
apk info -vv
apk info -vv | grep php8

Here is what I got on my dev machine:

php8-common-8.0.25-r0 - The PHP8 language runtime engine (common config)
php8-8.0.25-r0 - The PHP8 language runtime engine
php8-phar-8.0.25-r0 - PHP8 extension: PHP Archive
php8-curl-8.0.25-r0 - PHP8 extension: cURL
php8-iconv-8.0.25-r0 - PHP8 extension: Iconv
php8-mbstring-8.0.25-r0 - PHP8 extension: Multibyte String Functions
php8-openssl-8.0.25-r0 - PHP8 extension: OpenSSL
php8-zip-8.0.25-r0 - PHP8 extension: Zip

Print package names without version:

apk info -e -a