Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supabase start Error: Failed to connect to Docker daemon. Is Docker running? #167

Closed
nvme0 opened this issue Feb 7, 2022 · 39 comments
Closed
Labels
bug Something isn't working

Comments

@nvme0
Copy link

nvme0 commented Feb 7, 2022

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
@nvme0 nvme0 added the bug Something isn't working label Feb 7, 2022
@t-eckert
Copy link

t-eckert commented Feb 8, 2022

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

@nvme0
Copy link
Author

nvme0 commented Feb 9, 2022

Hey @t-eckert, thanks for the suggestion.

I have already added my user with root privileges to the Docker group, as you can see I can run docker commands but not supabase commands.

Screenshot_2022-02-09_21-01-15

Seems to be an issue with my setup, as it runs fine in the ci

@osaxma
Copy link
Contributor

osaxma commented Feb 9, 2022

@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?.

@nvme0
Copy link
Author

nvme0 commented Feb 9, 2022

@osaxma Thanks for the suggestion, I am running on Linux

@soedirgo
Copy link
Member

soedirgo commented Feb 9, 2022

What are the permissions for your docker binary? In my Linux box it's -r-xr-xr-x root root, which might explain why it runs w/ the old Node CLI (it just runs the docker binary) but requires superuser for the Go CLI.

This is probably related to the rootless mode mentioned above.

@haydn
Copy link

haydn commented Apr 18, 2022

I'm hitting this error trying to run the CLI in a Vercel build step.

This is the "Install Command" I'm running:

amazon-linux-extras install -y docker && systemctl enable docker && yum install -y https://github.com/supabase/cli/releases/download/v0.24.5/supabase_0.24.5_linux_amd64.rpm && yarn install

That command runs fine, but when I try to commit the database migrations:

supabase db remote set $POSTGRES_URL && supabase db remote commit

I get Docker daemon error message:

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

I can replicate this on my local (macOS) machine using the same build image Vercel uses:

$ docker run --rm -it amazonlinux:2.0.20191217.0 sh
sh-4.2# amazon-linux-extras install -y docker && systemctl enable docker && yum install -y https://github.com/supabase/cli/releases/download/v0.24.5/supabase_0.24.5_linux_amd64.rpm
sh-4.2# supabase init
sh-4.2# supabase start
Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
  in github.com/supabase/cli/internal/utils.AssertDockerIsRunning:26
  in github.com/supabase/cli/internal/start.Run:35

Unhelpfully, the AWS documentation mentions you might need to reboot an EC2 instance to fix Docker permission issues after installing:

image

Is there something really obvious I've missed here or any thoughts on how to work around this? I'm trying to keep the whole setup as simple as possible, but it's looking like I might need to get some other infrastructure involved to run the migrations (maybe GitHub Actions?).

@soedirgo
Copy link
Member

@haydn not familiar with Vercel, but are you able to run Docker containers in a Vercel build step? Same thing for the local repro.

@soedirgo
Copy link
Member

soedirgo commented Apr 18, 2022

Just tested the local repro myself, I worked when I did:

docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock amazonlinux:2.0.20191217.0 sh

@haydn
Copy link

haydn commented Apr 18, 2022

@soedirgo Thanks for the quick reply!

are you able to run Docker containers in a Vercel build step?

Nope, Vercel runs the Docker containers. All that is configurable are some commands to run within them:

image

@soedirgo
Copy link
Member

Can you check if you can run e.g. docker run hello-world in the build step?

@haydn
Copy link

haydn commented Apr 18, 2022

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?

@antonigiske
Copy link

antonigiske commented Oct 23, 2022

I have the same issue. docker ps and all other commands. Docker Desktop is running also. I've tried to restart both computer and docker multiple times to no avail. Any tips are welcome.

System information

OS: Mac 12.6
Version of Node.js: v16.13.0
Supabase CLI: 1.11.0
Docker: 20.10.20, build 9fdeb9c

@antonigiske
Copy link

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.

docker/for-mac#6529

It worked for me after downgrading.

@cravelight
Copy link

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.

@soedirgo
Copy link
Member

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

@sweatybridge sweatybridge closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2022
@sweatybridge
Copy link
Contributor

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

@amireldor
Copy link

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

@techandmedia
Copy link

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

@sweatybridge
Copy link
Contributor

sweatybridge commented Jan 20, 2023

@techandmedia could you post your error logs here? Generating types for a hosted project does not require docker https://supabase.com/docs/guides/api/generating-types.

The original issue is related to local development which we have documented that docker is a prerequisite.

@techandmedia
Copy link

@sweatybridge
This is how I run gen type

$ npx supabase login
$ npx supabase gen types typescript --db-url postgresql://postgres:[email protected]:5432/ppostgres
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Connecting to postgresql://postgres:[email protected]:5432/postgres
Error: error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdockker_engine/v1.24/images/public.ecr.aws/supabase/postgres-meta:v0.58.0/json": open //./pipe/docker_engine: The system cannot fnind the file specified.
Try rerunning the command with --debug to troubleshoot the error.
error Command failed with exit code 1.

@sweatybridge
Copy link
Contributor

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.

@techandmedia
Copy link

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.

@sweatybridge
Copy link
Contributor

sweatybridge commented Jan 20, 2023

Have you replaced connection with your actual project-id? Another thing to check is your access token used for login belongs to the account that has read permission to your project.

@techandmedia
Copy link

Hi @sweatybridge
Like this right? I am the only one who has access to this project and create the project

npx supabase gen types typescript --project-id postgresql://postgres:[email protected]:5432/postgres --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.

Where can I see this in the dashboard?
has read permission to your project

Also if you are free, can you have a look of this discussion raised by me as well? Thanks
supabase/supabase#11784

@sweatybridge
Copy link
Contributor

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

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.

@techandmedia
Copy link

Ah ok got, it works now, thanks @sweatybridge

@selbyk
Copy link

selbyk commented Mar 8, 2023

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

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

@abuuzayr
Copy link

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

@mlynch
Copy link

mlynch commented Apr 20, 2023

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.

@sweatybridge
Copy link
Contributor

Hi @mlynch, thanks for spotting this inconsistency in our guides. Yes, docker is indeed a prerequisite for managing environments. I've opened a PR to update the docs.

@raveesh-me
Copy link

@jojule
Copy link

jojule commented May 12, 2023

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

@yaronguez
Copy link

Curious, why is this issue resolved? Isn't this a bug with supabase? At the very least, I'd assume that supabase should update the docs on local development to save everyone from having to search for a fix on this thread.

@sweatybridge
Copy link
Contributor

sweatybridge commented Jun 5, 2023

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.

@PhE
Copy link

PhE commented Jun 8, 2023

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.

sudo ln -s ~/.docker/desktop/docker.sock /var/run/docker.sock

@yaronguez
Copy link

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.

@bertvh
Copy link

bertvh commented Jun 26, 2023

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

@dbustosp
Copy link

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

Thank you! This worked for me!

@chrisciszak
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests