Solution :
By default a docker daemon always runs as a root user, so you need to prepend sudo to the Docker command(s).
If you don’t want to use the sudo when you use a docker command, create the Unix group called docker and add the users to it. When a docker daemon starts, it makes a ownership of a Unix socket read/writable by a docker group.
To create a docker group and add to your user:
- Create a docker group.
$ sudo groupadd docker
- Next add your user to a docker group.
$ sudo usermod -aG docker $USER
- After that log out and log back in so that the group membership is re-evaluated.
- Next verify that you can docker commands without sudo.
$ docker run hello-world
This command downloads the test image and runs it in the container. When a container runs, it prints the informational message and exits.