Docker snap non-root user access

i am new to ubuntu core, i have Ubuntu core 20 VM and installed Docker Snap.
I am creating a service which needs to pull latest image and run docker container.

if i write docker command without sudo, below script is failing.

how to fix this, i read many topics about adding user to docker group, i am not able to find docker group after installing docker snap.

1 Like

Hi, unfortunately the docker snap is not currently usable without sudo on Ubuntu Core.

Based on ubuntu snap docker run as a normal user · GitHub it seems it is possible. It worked for me on Ubuntu 24.04.

Step 1: Create the ‘docker’ system group if it does not exist. This group is required by the Docker daemon for non-root access to its socket.

sudo addgroup --system docker

Step 2: Verify that the ‘docker’ group now exists. grep docker /etc/group You should see output like: docker:x:NNN: (where NNN is the GID)

Step 3: Add your user to the ‘docker’ group.

sudo adduser $USER docker

Step 4: Activate the new group membership for your current shell session. Alternatively, log out and log back in.

newgrp docker

Step 5: Disable and re-enable the docker snap. This ensures the snap’s environment picks up the changes in group membership.

sudo snap disable docker
sudo snap enable docker