cli icon indicating copy to clipboard operation
cli copied to clipboard

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

Open nvme0 opened this issue 3 years ago • 11 comments

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 avatar Feb 07 '22 08:02 nvme0

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

t-eckert avatar Feb 08 '22 02:02 t-eckert

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

nvme0 avatar Feb 09 '22 11:02 nvme0

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

osaxma avatar Feb 09 '22 11:02 osaxma

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

nvme0 avatar Feb 09 '22 11:02 nvme0

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.

soedirgo avatar Feb 09 '22 19:02 soedirgo

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

haydn avatar Apr 18 '22 06:04 haydn

@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 avatar Apr 18 '22 06:04 soedirgo

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

soedirgo avatar Apr 18 '22 06:04 soedirgo

@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

haydn avatar Apr 18 '22 06:04 haydn

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

soedirgo avatar Apr 18 '22 07:04 soedirgo

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?

haydn avatar Apr 18 '22 09:04 haydn

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 avatar Oct 23 '22 21:10 antonigiske

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.

antonigiske avatar Oct 23 '22 22:10 antonigiske

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.

cravelight avatar Oct 26 '22 04:10 cravelight

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

soedirgo avatar Oct 26 '22 04:10 soedirgo

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

sweatybridge avatar Nov 27 '22 06:11 sweatybridge

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

amireldor avatar Jan 09 '23 22:01 amireldor

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

techandmedia avatar Jan 20 '23 03:01 techandmedia

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

sweatybridge avatar Jan 20 '23 04:01 sweatybridge

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

techandmedia avatar Jan 20 '23 06:01 techandmedia

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.

sweatybridge avatar Jan 20 '23 07:01 sweatybridge

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.

techandmedia avatar Jan 20 '23 08:01 techandmedia

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.

sweatybridge avatar Jan 20 '23 08:01 sweatybridge

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 https://github.com/supabase/supabase/discussions/11784

techandmedia avatar Jan 20 '23 09:01 techandmedia

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.

sweatybridge avatar Jan 20 '23 09:01 sweatybridge

Ah ok got, it works now, thanks @sweatybridge

techandmedia avatar Jan 20 '23 09:01 techandmedia

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

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

selbyk avatar Mar 08 '23 21:03 selbyk

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

abuuzayr avatar Mar 29 '23 01:03 abuuzayr

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.

mlynch avatar Apr 20 '23 21:04 mlynch

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.

sweatybridge avatar Apr 21 '23 00:04 sweatybridge