I followed the instruction from DigitalOcean to install Docker and Docker Compose on Ubuntu 22.04. However, when trying to run docker run hello-world, I received the following error:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

This was due to Ubuntu 22.04 having issues with iptables. To resolve this, I had to switch it back to legacy version.

  1. Update the iptables and set it back to iptables-legacy.
    sudo update-alternatives --config iptables
    
  2. Restart docker service.
    sudo service docker start
    
  3. Confirm that docker is running.
    sudo service docker status