After I created a clean instance with Ubuntu 20 or Amazon Linux AMI, I can log into the instance using SSH.
Then I do:
sudo apt update -y && apt upgrade -y on Ubuntu
or
sudo yum update -y on Amazon Linux
Still all goes fine and I can continue to connect to the instance via SSH.
Then I install docker, the pipe becomes broken in the middle of the installation and I cannot connect to the instance any more. The SSH times out.
This same behavior can be observed also with AMIs with preinstalled Docker on them. For example I tried to use the redash AMI, I couldn't connect to it after launch.