The %post section in Apptainer .def files runs as /bin/sh by default, which does not support Bash arrays ((...) and ${array[@]}).
Add a shebang as the first line of %post:
diff%post + #!/bin/bash apt update packages=( htop vim ) apt install -y "${packages[@]}"
diff%post apt update - packages=( - htop - vim - ) - apt install -y "${packages[@]}" + apt install -y htop vim
or with a space-separated string:
diff%post apt update + packages="htop vim" + apt install -y $packages
Use Option 1 if you need arrays; otherwise, Option 2 is simpler and more portable.
Le Chat can make mistakes. Check answers. Learn more