I had the same issues. The snap installation restricts permissions see https://snapcraft.io/install/docker/ubuntu first bullet point - probably for good security reasons given docker can give unlimited root privileges...).
First, sudo snap remove docker --purge
to get rid of it. (from @jorgeca's comment).
Second, following the official installation guide
### remove any previously installed docker remnants
sudo apt-get remove docker docker-engine docker.io containerd runc
### install ca-certificates
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg
### install docker certs
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
### setup docker repo
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
### install docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
### test installation
sudo docker run hello-world
I also did the following - tests installation binding a volume not in $HOME. This will error out with a snap installation of docker saying the filesystem is read-only.
sudo mkdir /test
sudo docker run -v /test:/test hello-world
sudo rmdir /test