flyctl cannot find local docker instance

Hi,
recently I’ve started having problems with local only deployments, and found through fly doctor that the local docker instance is not found.

This started happening maybe a couple weeks ago, it could have been a bit longer since my latest local deploy, so it should only be in recent versions of the cli.

I’m on an M1 mac for reference with:

flyctl v0.0.496 darwin/arm64 Commit: 01c3cfdb BuildDate: 2023-03-21T16:47:35Z
Docker version 20.10.23, build 7155243
Docker Desktop 4.17.0 (99724)

These should all be the newest versions available today.

Here’s the relevant part of fly doctor results (everything else is PASSED):

Testing authentication token... PASSED
Testing flyctl agent... PASSED
Testing local Docker instance... Nope
Pinging WireGuard gateway (give us a sec)... PASSED

...

Checking docker context size (this may take little bit)... PASSED (49 MB)
Checking for .dockerignore... PASSED

Is there anything I could try to fix this locally, or could it be a cli bug?

Can you check if DOCKER_HOST is set in your environment with env | grep DOCKER_HOST? Having that set would override the default local Docker check.

I have checked, it’s not set

Can you run fly doctor --verbose?

Looks like under the hood in flyctl, fly doctor is calling the Docker client ping method which calls the Docker daemon API’s /_ping method.

That is doing something like this (on my m2 mac with the official Docker Desktop):

Can you replicate that locally? Do you get an error response?

I’ll bet restarting Docker Desktop will resolve this.

Ok I’ve figured it out.

Running docker context ls shows:

which is as expected, but unix:///var/run/docker.sock does not exist.
Turns out that Docker for Mac does not create a symlink anymore to the default endpoint, at least for fresh installs. Since v4.15 it doesn’t run as root anymore, so it doesn’t have permissions to create this symlink.

In the docker docs it’s written, I’ve simply added the symlink and now it works correctly.

It might make sense for flyctl to check both locations, or at least include this in the flyctl docs, as Docker Desktop starts automatically on the desktop-linux context and creates the socket in the user directory where it can write.

2 Likes

Hi!

Thanks for the details -

To be clear, /var/run/docker.sock wasn’t created on a fresh install of newer Docker Desktop, right?

And the symlink you created manually to /var/run/docker.sock points to ~/.docker/run/docker.sock ?

It looks like mine is a symlink now also, interesting!

Yes, correct. I created the /var/run/docker.sock just like you described.
I also don’t have te other sockets you have on a fresh install. I have docker-cli.sock at the same path you do but no symlink by default.

1 Like

I created an issue here Look for docker socket in ~/.docker/run/docker.sock · Issue #1939 · superfly/flyctl · GitHub

2 Likes

I’ve added some details on the issue, this thread can be closed as far as I’m concerned

This comment solved the issue for me.

Hi there y’all.
Just reporting here that yesterday I’ve experience the same issue (fly cli can’t find docker locally) on my Ubuntu 22 laptop.

This is a new Ubuntu laptop I’ve installed a few months ago.
This thread helped me find and fix the issue.

But my case was a bit different.
fly doctor was expecting /var/run/docker.sock but it was created under ~/.docker/desktop/docker.sock

Here is the ln command:

$ sudo ln -s  /home/hac/.docker/desktop/docker.sock /var/run/docker.sock

This command also helped me:

$ netstat -na | grep docker.sock

My 5 cents.