Sounds like it could be a permission issue. Check that the pi user is in the docker group by running the following: groups
If you don't see docker in the reply, you will need to add the user to the group, if it exists, by running the below:
sudo groupadd docker
sudo usermod -aG docker $(whoami)...