I am attempting to create a docker image via docker-py and I am using the following code:
docker_client = docker.from_env()
path = os.path.dirname(os.path.abspath(__file__)) + "/container"
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
docker_client.containers.list() works for you, your issue is not with docker connection. It is that the build is failing for some reason.
journalctl -f -n10 in another terminal and then run your code and see if you can find what is going wrong. That will give your clear exception happening when you call