abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
18.62k stars 380 forks source link

Python Docker SDK cannot create client from_env #468

Open adrianmace opened 1 year ago

adrianmace commented 1 year ago

Description

After switching from Docker Desktop to Colima, tooling written in Python which creates a Docker client using from_env() fails with the following error:

Error connecting to Docker: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

Version

Colima Version: 0.4.6 Lima Version: 0.13.0 Qemu Version: 7.1.0

Operating System

Reproduction Steps

import docker
client = docker.from_env()

Expected behaviour

Client is an instantiated Docker client object.

Additional context

I understand that this is probably not your concern given it is the official Docker Engine SDK that is breaking.

However, given Colima is designed to be an alternative way of running Docker on your workstation it would be great to have a workaround so it can continue to work as a drop-in replacement for Docker Desktop.

abiosoft commented 1 year ago

Have you tried specifying the DOCKER_HOST environment variable?

export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
abiosoft commented 1 year ago

However, given Colima is designed to be an alternative way of running Docker on your workstation it would be great to have a workaround so it can continue to work as a drop-in replacement for Docker Desktop.

The decision to not override default Docker settings but instead utilise contexts and a different socket is to make it easy for users to try out Colima without breaking their existing workflow.

adrianmace commented 1 year ago

Thanks for the fast reply! The issue is fixed when I set this and the reason for using contexts makes a lot of sense.

It looks like we'll need to update our tooling to check for both the default location as well as colima default location depending on what our users are using.

Is there a potential future where you allow users the option to force override the default docker settings instead? This is the route we'd likely prefer if we asked our users to make the switch.

Overall I've been trialing this workflow for the last few weeks and absolutely love it! Thanks for some great software 😄

abiosoft commented 1 year ago

Is there a potential future where you allow users the option to force override the default docker settings instead? This is the route we'd likely prefer if we asked our users to make the switch.

This has been requested a few times now and will be prioritised for the next release.

abiosoft commented 1 year ago

FYI, the command to override the default socket can be found in the FAQ.

sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
adrianmace commented 1 year ago

I'm happy for you to close this with whichever state you think is most appropriate.

Thank you again for the information provided.

abarrak commented 1 year ago

Thanks @abiosoft the symlink solves this.

stowns commented 8 months ago

Neither of these fixes appear to be helping for Apple M2 Pro, colima 0.6.7, docker 24.0.7, and the localstack image. Still throws Creating Docker SDK client failed: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory')).