This article covers methods to resolve AWS EC2 docker permission denied error.
To give docker user enough permission, do the following:
You can try adding prod-user to group Docker:
$ sudo usermod -a -G docker $USER
usermod is a command that modifies the system configuration for a specific user.
-a is a shortcut for --append: It means append the group to the list of groups the user belongs to.
-G is a shortcut for --groups: It tells usermod that the next argument is a group.
docker is the group we want to add $USER to.
$USER is the user that we want to modify.
If this alone doesn't resolve the issue then try below :
$ chmod 664 /var/run/docker.sock ## First try this.
$ chmod 777 /var/run/docker.sock ## Then this. Not recommended though due to full permission.