1

In the Python Docker SDK, When I do

import docker

docker.from_env()

I see

docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

I have docker desktop running and this works in the terminal

$ docker run -it ubuntu

If I add a version number

docker.from_env(version="6.0.1")

it stops erroring, but it doesn't seem to matter what number I use. I also then see an error on

client.containers.run("ubuntu")

of

requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

I'm on Ubuntu 22.04 and I'm seeing the problem with both Poetry and plain pip + venv. I've looked through the dozen or so questions about that error message and tried everything that looked relevant.

5
  • Is there more of the error than that? Are you using Docker Desktop, or just plain Docker? Do you have a $DOCKER_HOST environment variable set, or a non-default docker context? Commented Jan 25, 2023 at 14:12
  • @DavidMaze will get more error logs. Docker desktop. re $DOCKER_HOST probably not (nothing shows in a fresh terminal). Don't know what the docker context is so probably default Commented Jan 25, 2023 at 14:47
  • I have a docker context desktop-linux in addition to my default (if I docker context list). Each context has a different endpoint Commented Jan 25, 2023 at 15:03
  • This seems the same as docker/docker-py#3059, and that issue suggests a symlink-based workaround. It may be a problem specifically with Docker Desktop 4.13.0. Docker Desktop isn't really necessary on native Linux, though; if you uninstall it and use a non-VM Docker daemon, do things work better? Commented Jan 25, 2023 at 15:59
  • @DavidMaze that looks likely. I may well remove docker desktop now it's got in the way Commented Jan 25, 2023 at 20:36

2 Answers 2

1

My final solution was to uninstall Docker Desktop and install Docker Engine instead. I had to manually delete some Docker config files left over after installation too.

Sign up to request clarification or add additional context in comments.

2 Comments

For me reinstalling Docker Desktop was also working.
Same here on MacOS after installing xcode. See here the details to uninstall stackoverflow.com/a/76318769/3703307
1

If you're running MacOS, uninstall Docker using: /Applications/Docker.app/Contents/MacOS/uninstall and then install a fresh version for Docker Desktop. Be sure to choose the appropriate chipset.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.