Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Docker SDK cannot create client from_env #468

Open
1 of 3 tasks
adrianmace opened this issue Nov 8, 2022 · 8 comments
Open
1 of 3 tasks

Python Docker SDK cannot create client from_env #468

adrianmace opened this issue Nov 8, 2022 · 8 comments

Comments

@adrianmace
Copy link

adrianmace commented Nov 8, 2022

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

  • macOS Intel
  • macOS M1
  • Linux

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
Copy link
Owner

abiosoft commented Nov 8, 2022

Have you tried specifying the DOCKER_HOST environment variable?

export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"

@abiosoft
Copy link
Owner

abiosoft commented Nov 8, 2022

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
Copy link
Author

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
Copy link
Owner

abiosoft commented Nov 8, 2022

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
Copy link
Owner

abiosoft commented Nov 8, 2022

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
Copy link
Author

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

Thank you again for the information provided.

@abarrak
Copy link

abarrak commented May 23, 2023

Thanks @abiosoft the symlink solves this.

@stowns
Copy link

stowns commented Jan 4, 2024

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')).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants