Coder Social home page Coder Social logo

Comments (10)

keeb-zz avatar keeb-zz commented on August 25, 2024

I've started working on a unix socket patch to requests which will allow this to work.

from docker-py.

keeb-zz avatar keeb-zz commented on August 25, 2024

Some minor notes so far. The goal will be to reuse as much of the HTTPAdapter as possible and only patch in the places that need to change. Requests is pretty modular, but has pretty complicated connectionpool logic.

requests.Session has a mount method that allows for custom protocol handlers to be registered with an associated adapter.

My thinking is that inheriting and initializing the requests.adapter.HTTPAdapter and overwriting the get_connection method is the least invasive way to do it.

from docker-py.

keeb-zz avatar keeb-zz commented on August 25, 2024

See attached patch for a WIP: https://gist.github.com/keeb/bf39ef50677d4b2ae3dd

The biggest hurdle right now is that there is no reliable way to separate a unix socket file from the rest of the parameter string. Separating the two would mean that we'd have to change the interface, which is something I would like to avoid if at all possible.

This would be trivial if we did not use requests but instead used httplib directly.

Thoughts?

from docker-py.

kstaken avatar kstaken commented on August 25, 2024

How far along should the patch get? I get the error below but I'm guessing maybe that's expected at this stage.

requests.exceptions.InvalidURL: Invalid URL u'unix:///var/run/docker.sock/v1.4/containers/create': No host supplied

from docker-py.

keeb-zz avatar keeb-zz commented on August 25, 2024

@kstaken - it's a little backward, but the problem is the URL you're passing in to the client. It should be unix://var/run/docker.sock (notice, only 2 /'s)

a simple test is

import docker
c = docker.Client(base_url="unix://var/run/docker.sock")
print c.version()

from docker-py.

kstaken avatar kstaken commented on August 25, 2024

@keeb the URL came from your patch. The default base_url :-)

And wouldn't 3 slashes actually be correct anyway? unix:// is the scheme and then the path is /var/run/docker.sock although it seems maybe that wouldn't work with requests.

from docker-py.

kstaken avatar kstaken commented on August 25, 2024

@keeb do commands other than c.version() work for you?

from docker-py.

kstaken avatar kstaken commented on August 25, 2024

oh, I see _extract_path is just hard coded to return /version at the moment.

from docker-py.

keeb-zz avatar keeb-zz commented on August 25, 2024

Patch incoming..

from docker-py.

shin- avatar shin- commented on August 25, 2024

Thanks @keeb !

from docker-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.