Fly deploy permission denied connecting to Docker daemon

I was going through the “Hands on with Fly.io” tutorial with my own Docker image and am running into some errors with the fly deploy command.

fly deploy
==> Verifying app config
--> Verified app config
==> Building image
Searching for image 'xmeng999/bug-tracker-api:latest' remotely...
Error failed to fetch an image or build from source: Authentication required to access image "docker.io/xmeng999/bug-tracker-api:latest"
fly deploy --local-only --verbose
==> Verifying app config
--> Verified app config
==> Building image
WARN Error connecting to local docker daemon: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied
Error failed to fetch an image or build from source: no docker daemon available

fly.toml:

# fly.toml file generated for bug-tracker on 2022-09-23T21:10:35-06:00

app = "bug-tracker"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  image = "xmeng999/bug-tracker-api:latest"

[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Dockerfile:

FROM node:18

WORKDIR /app

COPY package*.json ./
COPY prisma ./prisma

RUN npm install

COPY . .

RUN npm i -g prisma
RUN prisma generate

ENV PORT=5000
EXPOSE 5000

CMD [ "npm", "start" ]

This doesn’t work since Fly’s remote builders don’t fetch images from private repositories: Feature request: Images from private Docker registries - #2 by kurt

You can choose to push your private docker images to Fly, however: Session affinity ("sticky sessions")? - #9 by kurt | Requesting recommendations for making Fly less flaky for CI - #2 by ignoramous

I haven’t seen this before, but sounds like docker may be running with tighter permissions than usual: jenkins - Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock - Stack Overflow