https://github.com/dotcloud/docker-py
> sudo pip install docker-py
..
> python
>>> import docker
>>> c = docker.Client(base_url='unix://var/run/docker.sock', version='1.8', timeout=10)
>>> c.info()
{u'KernelVersion': u'3.2.0-4-amd64', u'NFd': 10, u'MemoryLimit': 0, u'InitSha1': u'', u'SwapLimit': 0, u'Driver': u'aufs', u'IndexServerAddress': u'https://index.docker.io/v1/', u'NGoroutines': 15, u'Images': 109, u'InitPath': u'/usr/local/bin/docker', u'Containers': 11, u'LXCVersion': u'0.8.0-rc1', u'Debug': 0, u'NEventsListener': 221, u'DriverStatus': [[u'Root Dir', u'/var/lib/docker/aufs'], [u'Dirs', u'135']], u'IPv4Forwarding': 1}
>>> help(c.containers)
Help on method containers in module docker.client:
containers(self, quiet=False, all=False, trunc=True, latest=False, since=None, before=None, limit=-1) method of docker.client.Client instance
(Caution:The above location is displayed in LESS or changes depending on the environment)
>>> c.containers(all=True)
[{u'Command': u'do not look at me',
u'Created': 1391059918,
u'Id': u'97115535aacbba9fcf19bbd9bc8ca9aac66132f79acf2820d6225a554b06191d',
u'Image': u'griflet:oajxuu024euvttj0ar0s-23b235cf82b0301f864f6ad100a2b3245b7dca7d',
u'Names': [u'/drunk_heisenberg'],
u'Ports': None,
u'SizeRootFs': 0,
u'SizeRw': 0,
u'Status': u'Exit 0'},
{u'Command': u'do not look at me',
u'Created': 1391059896,
u'Id': u'5c796656a414673ead3c74aaafd95ae6f80c00125eda8cf01ea826b76eca7586',
u'Image': u'54055ba1f6fe',
u'Names': [u'/pensive_galileo'],
u'Ports': None,
u'SizeRootFs': 0,
u'SizeRw': 0,
u'Status': u'Exit 0'},
{u'Command': u'do NOT look at me :-)',
..
(docker ps basically)
In ipython, if you insert Tab after "c.", Candidates will appear, so it may be easier to understand than a half-finished shell environment.
Recommended Posts