Search code examples
memgraphdb

Permission denied when Installing Memgraph on Ubuntu VM in Google Cloud with Docker


I'm trying to install Memgraph on a Ubuntu VM instance running on Google Cloud. I have Docker installed, and it seems to be working correctly. However, when I run the installation command:

curl https://install.memgraph.com/ | sh

I get the following error:

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: 
Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.46/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.project%3Dmemgraph-platform%22%3Atrue%7D%7D": 
dial unix /var/run/docker.sock: connect: permission denied

Solution

  • This issue is likely due to user not having the necessary permissions to access the Docker daemon socket. This can be resolved by creating a Docker group, adding your user to that group, and then re-logging in to apply the changes.

    Shor version is: create a docker group, add user account to that group, re-login, and verify that docker run hello-world works without sudo.

    Here are the steps:

    1. Create the Docker group (if it doesn't already exist):

      sudo groupadd docker
      
    2. Add your user to the Docker group:

      Replace your-user with your actual username:

      sudo usermod -aG docker $USER
      
    3. Re-login to apply the group membership:

      You can either log out and log back in or use the following command to refresh the group membership without logging out:

      newgrp docker
      
    4. Verify that Docker is working without needing sudo:

      Run the following command:

      docker run hello-world