Once you have installed the Docker Engine in your machine and when you access the docker commands like create or list out the docker containers from your USER account, you may received an error, Got permission denied while trying to connect to the Docker daemon socket. I will display here the full error,
Error:

​$ docker container ls

output:
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

which means, you (current $USER) don't have permission to access docker commands, so set the permission for non-root user then you need to add it to the docker group,

Create a docker group if it does not exist already in your machine. The Group may created hopefully,
$ sudo groupadd docker


Add your user to the docker group.
$ sudo usermod -aG docker $USER


Execute the command below or Logout and Login to the user account and execute the docker commands,
$ newgrp docker


Another option is,

You can change the permissions of docker socket to be able to connect to the docker daemon /var/run/docker.sock
$ sudo chmod 666 /var/run/docker.sock 


Do the TEST:

Even, if doesn't have permission to access the docker commands, reboot and check it again. It should be working fine. Next, run the docker container with NGINX latest version.
$ docker run -itd --name nginx -p 8080:80 nginx:latest 




List out the running container,
$ docker container ls

output:
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                   NAMES
f5b952237f5a   nginx:latest   "/docker-entrypoint.…"   24 seconds ago   Up 17 seconds   0.0.0.0:8080->80/tcp, :::8080->80/tcp   nginx