There are a couple things to check..
1. Issue "db2set -all" and see if DB2COMM=TCPIP is set. If not, you want to set it "db2set db2comm tcpip"
2. Make sure that your db2 instance is set to a port to communicate on - db2 "get dbm cfg" - the SVCENAME should be set to a port number. If it is set to a string like "db2c_db2inst1" confirm that string is in /etc/services and set to a port like 50051
3. Look in your error log after you try to connect and see if there is an error message reported with more details. The default location is in the instance home directory /sqllib/db2dump and the file is called db2diag.log
And as mentioned before, reboot the VM or the docker image, it may clear things up.
------------------------------
Michael Krafick
------------------------------