1. Is there a way to encrypt a Perl file containing password? I need to import database credentials from a file and would like to know more about encrypting passwords
Since you mentioned Docker...
If you need something that scales in a large environment, i.e. multiple nodes requiring credentials and that also works for unattended (re-)boots, have a look at
HashiCorps Vault (client: i.e. WebService::HashiCorp::Vault, server: https://github.com/hashicorp/vault). There is still a secret to be kept (i.e. token),
however, management of credentials becomes much more feasible at the cost of running a dedicated centralised (hopefully redundant) vault service.