cli: `supabase start` Error: Failed to connect to Docker daemon. Is Docker running?

Bug report

Describe the bug

Recently updated to supabase 0.17.0, and when running supabase start I get the following error message:

Error: Failed to connect to Docker daemon. Is Docker running?

Using the npm package (0.5.0) I have no issues running supabase start.

edit: It starts fine when running as a super user

System information

  • OS: Linux
  • Version of Node.js: v14.17.1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 39 (13 by maintainers)

Most upvoted comments

On MacOS, this fixes the situation for me: export DOCKER_HOST=unix:///$HOME/.docker/run/docker.sock

You can also use the DOCKER_HOST env for now (in ~/.bashrc, etc.) until this is fixed upstream:

DOCKER_HOST=unix:///Users/me/.docker/run/docker.sock supabase start

@nvme0 if you’re using Mac (I believe this applies to Windows as well), you need to have Docker Desktop running.

docker -v will run without the Desktop app but if you try to run any container or simply run docker ps, you’ll get the following error:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

FYI: I just installed 4.20.1 for Mac and had to check a box in settings after installation to enable this.

Screenshot 2023-06-26 at 09 59 01 Medium

FYI: I just installed 4.20.1 for Mac and had to check a box in settings after installation to enable this.

Screenshot 2023-06-26 at 09 59 01 Medium

This fixed it on my MacOS

I just went ahead and created the symbolic link and it worked for me. I’m upgrading to a new machine next week anyway, so this one will be wiped. 😃

ln -s /users/me/.docker/run/docker.sock /var/run/docker.sock

I had to sudo it.

if you are using colima do this instead

DOCKER_HOST=unix:///$HOME/.colima/docker.sock supabase start

or of course add it to your .bashrc / .zshrc

Closing this as won’t fix because docker is a prerequisite for using the CLI.

There’s no mention in the doc that docker is prerequisite; can you add it there as I lost hours trying to generate types and the doc just mention to run the command. I thought my connection is bad

This was using latest Docker Desktop. After reading the release notes I noticed this on 4.13.0:

By default Docker will not create the /var/run/docker.sock symlink on the host and use the docker-desktop CLI context instead.

https://github.com/docker/for-mac/issues/6529

It worked for me after downgrading.

If it starts fine when running as a super user, you almost certainly have the Docker daemon running. Two things you can consider

  • Update your Docker engine to a version >19 which is able to run rootless.
  • Add your user with root privileges to the Docker group: sudo usermod -aG docker $USER.

Reference

Docker Engine Release Notes

Closing this as won’t fix because docker is a prerequisite for using the CLI.

@sweatybridge is Docker a prerequisite for following the Managing Environments guide? Because I’m also getting this issue and I don’t see Docker mentioned on that page. That page is linked to in a few places and skips the Local Development guide so it’s understandable that Docker might not be installed if you’ve previously only been using the supabase.com dashboard. Going to install it and hope it fixes it though. Update: installed Docker and it’s working fine now, could be good to add to that guide.

The --db-url flag is mostly used for self-hosted setup. For platform projects, we suggest using --project-id flag as documented.

npx supabase login
npx supabase gen types typescript --project-id myconnection --schema public > types/supabase.ts

I will update the cli reference docs to make this distinction clearer.

This is a future reference to myself. On Linux, I did something like this (I use Docker Desktop):

export DOCKER_HOST=unix:///home/amir/.docker/desktop/docker.sock

Sorry, I probably should’ve included that in my first comment.

Just running docker info yields the same error:

sh-4.2# docker info
Client:
 Context:    default
 Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

We closed this issue because it is specific to user’s docker installation. Since Docker Desktop 4.14.0, the socket file /var/run/docker.sock has been added back to default installation options. If you installed docker without letting it create symlinks to finish the default setup, not only supabase but other programs like docker-py would also not work.

Hence, I don’t consider this a bug specific to the CLI. But I will go ahead and document the DOCKER_HOST workaround in our troubleshooting guide.

Thanks! I encountered this problem after installing Docker Desktop for macOS version 4.20.0 and I did not do anything special during the installation or deny it any requested access.

export DOCKER_HOST=unix:///home/amir/.docker/desktop/docker.sock

Took me longer than I care to admit to realize I needed 3 /'s

Your project id is part of the url you use to access supabase.com: https://app.supabase.com/project/<project-id>

Alternatively use supabase projects list to find it. Please open a separate issue if the error still exists. As explained before, this thread is meant for self-hosted only.

Hi @sweatybridge thank you for your reply, but I still got error, though it’s different

$ npx supabase gen types typescript --project-id connection --schema public > types/supabase.ts
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Error: failed to retrieve generated types: {"message":"Forbidden resource"}
Try rerunning the command with --debug to troubleshoot the error.
error Command failed with exit code 1.