cli icon indicating copy to clipboard operation
cli copied to clipboard

`supabase start` fails when launched inside a container

Open clouedoc opened this issue 4 years ago • 3 comments

Bug report

Describe the bug

When running Supabase inside a Docker container with a docker-host-socket to container setup (container has access to the host's Docker socket), when running supabase start, Supabase tries to bind a volume from the host into another container.

➜  opinionshift git:(feat-devcontainer) supabase start 
Error: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/workspace/opinionshift/supabase/.temp/userlist.txt" to rootfs at "/etc/pgbouncer/userlist.txt" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
➜  opinionshift git:(feat-devcontainer) 

Reproduction

See reproduction repository

Expected behaviour

A clear and concise description of what you expected to happen.

System information

  • OS: Docker container inside a Linux host

Additional context

Faulty code

https://github.com/supabase/cli/blob/59245bbb98cd9847075dbb8e455aad84de938152/internal/start/start.go#L716-L720

and

https://github.com/supabase/cli/blob/59245bbb98cd9847075dbb8e455aad84de938152/internal/start/start.go#L676-L683

Possible solutions

  • [ ] using volumes instead of filesystem binds (note: there might be networking issues too)
  • [x] using Docker in Docker

Checklist for PR creator

  • [ ] removing filesystem bindings
  • [ ] checking that sibling container-to-container communications work

clouedoc avatar Dec 01 '21 18:12 clouedoc

Thanks for the report! Running in Docker isn't supported atm, but if it can work w/o too much hassle I have no problem with that.

soedirgo avatar Dec 02 '21 09:12 soedirgo

instead of docker from docker, I used docker in docker and it works. image

turkerdev avatar Dec 03 '21 11:12 turkerdev

instead of docker from docker, I used docker in docker and it works.

@bajosiaa thank you so much! I didn't think that VSCode's devcontainers supported this natively.

EDIT: I can confirm that it works

image

Edited my devcontainer.json this way:

  "runArgs": [
+    "--privileged",
+    "--init"
  ],
+  "features": {
+    "docker-in-docker": {
+      "version": "latest",
+      "moby": true
+    }
+  },
+  "overrideCommand": true, // note: setting this to `false` makes the container exit right way for some reason

clouedoc avatar Dec 03 '21 12:12 clouedoc