After installing docker on Ubuntu 20.04, in order to run docker commands against the docker daemon, you must add the user to the docker group. If a permissions denied state persists, try logging out and back in again before running additional commands.
The most common error message is:
~$ docker container list Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied
If you are using the ubuntu user, try this command:
usermod -g ubuntu -G sudo,docker,ubuntu
Next, logout and back in again, and try a docker command.
Some internet postings will tell you to chmod the docker.sock, or other things, but that is not correct. They just need to logout and back in to reset their session.