Why I try a “local only” deploy, I get the message “Error failed to fetch an image or build from source: docker is unavailable to build the deployment image” even though Docker seems to be running.
$ fly deploy --local-only
==> Verifying app config
--> Verified app config
==> Building image
Error failed to fetch an image or build from source: docker is unavailable to build the deployment image
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
I’m using Docker Desktop on macOS 12.6 (M1) and it starts without problems.
What could be the issue?
EDIT: fly doctor also tells me Docker is not running:
% fly doctor
Testing authentication token... PASSED
Testing flyctl agent... PASSED
Testing local Docker instance... Nope
Pinging WireGuard gateway (give us a sec)... PASSED
App specific checks for railsbump:
Checking that app has ip addresses allocated... PASSED
Checking A record for railsbump.fly.dev... PASSED
Checking AAAA record for railsbump.fly.dev... PASSED
Docker desktop is the right thing to be using on Mac machines. The issue isn’t docker desktop. The issue is attempting to build an intel/amd64 image on a M1. The tools apple uses to emulate intel hardware have a bug that will prevent you from getting this to work.
Fly makes use of Docker’s own client libraries to find the daamon: moby/client at master · moby/moby · GitHub (note that if you click on the URL it will take you to “moby” which is the new name for the toolkit).
So the question is: why can’t docker’s own client libraries find the Docker deamon launched on your machine? I wish I could help you there, but it works on my M1 macbook.
Some things that may help identify what’s not working:
Re-run with LOG_LEVEL=debug fly deploy --local-only and see if additional errors/info get printed about what’s failing.
Try building the docker image using the docker client. From the directory with your Dockerfile: docker build --platform linux/x86_64 -t yourapp:local . (don’t miss that period at the end there). That might give some additional errors or logs that indicate what’s not working. Also try docker buildx build --platform linux/x86_64 -t yourapp:local . At least one of those should work without issue, and if they aren’t fly deploy --local-only will also not work.
Try updating docker desktop, stopping and restarting the virtual machine it uses, and ensuring that docker info works after.
There might be some logs in ~/Library/Containers/com.docker.docker/Data/log/ that indicate what’s not working or failing.
For background, the fly doctor check attempts to create a docker client connected to the default server and then calls the docker client Ping(), and if anything in there fails fly doctor will print Nope. This is the same code path that is used during fly deploy --local-only to create the dockerclient. I don’t know if there is an exact equivalent to the docker go library’s ping, but docker info shows some similar information and if that’s also not working might give some clues.
Still, this doesn’t explain why flyctl can’t find the Docker daemon in the first place, right?
Not a huge problem for me right now, since remote deploys work just fine most of the time, but I was interested to see if local deploys would save some time…