Package: tsaotun
Q: I can’t figure out why I would need thisA:In traditional ways, we make aliases ourselves all over the Docker commands.The reason why I develop this project is to encourage people to contribute and share their ideas and thoughts into plugins, which would give Tsaotun ability to do those things. And, the aboved thing is just one of things that Tsaotun can achieve, you will be able to load variety of plugins in the future as well.Besides, if you are doing some projects involved running containers, Tsaotun has provide the higher level API for you. That is another helpful functionality.Currently, I’m moving my previous projectVWGeninto one of Tsaotun’s plugin. Once I finish, everyone can just load the plugin and extend the power of Tsaotun.Contents1Main features2Installation (All platforms)2.1pip2.2Docker hub3Usage4Addon4.1Best practices (Sample addon to remove “ALL” containers at once, no matter it’s dead or alive)5Licence6Author1Main featuresRun any commands docker can run on TsaotunAll written in Python with love of API of dockerSimplify the process making your own implementation of docker command line toolMany Addons are upcoming2Installation (All platforms)2.1pipA universal installation method (that works on Windows, Mac OS X, Linux, and always provides the latest version) is to usepip:# Make sure we have an up-to-date version of pip and setuptools:$pipinstall--upgradepipsetuptools$pipinstall--upgradetsaotun(Ifpipinstallation fails for some reason, you can tryeasy_install tsaotunas a fallback.)2.2Docker hubPull fromdockerhub, or build it yourself:$dockerbuild-ttsaotun.Verify that now we have installed the latest version, for example:$tsaotunversionClient:Version:0.8.1Pythonversion:2.7.13OS/Arch:Darwin/x86_64Server:Version:1.13.0-rc7APIversion:1.25(minimumversion1.12)Goversion:go1.7.3Gitcommit:48a9e53Built:5daysagoOS/Arch:linux/amd64Kernelversion:4.9.3-mobyExperimental:True3UsageHello World:$tsaotun[COMMAND]Synopsis:$tsaotun[-h][--console][--color][--debug][--dry][--hostlist][--verbose]{version,info,inspect,container,image,network,volume,addon}...See alsotsaotun--help.4AddonAddon feature is testing right now, and each addon should has its own folder with__init__.pyinside.Addon folder struture shows like:$HOME
└───Tsaotun
    └───addons
        ├── addon_A - __init__.py, ...
        ├── addon_B - __init__.py, ...
        └───__init__.py4.1Best practices (Sample addon to remove “ALL” containers at once, no matter it’s dead or alive)__init__.py: To specify how to override the original command"""Configuration file for this addon"""from.Containerimportrm__override__={'Container.rm':'Rm'}__argparse__=[{'namespace':"Container",'position':"Child",'subcommand':"rm",'actions':["add_argument('--clear',\action='store_true',\dest='clear',\help='Remove all dead and alive containers.\You still need to give a whatever container ID.')",],},]Container/rm.py"""This module contains `docker container rm` class"""fromdocker.errorsimportAPIErrorfromtsaotun.lib.Docker.Container.commandimportCommandfromtsaotun.cliimportTsaotunclassRm(Command):"""This class implements `docker container rm` command"""name="container rm"require=[]def__init__(self):Command.__init__(self)self.settings[self.name]=Nonedefeval_command(self,args):try:containers=args["containers"]clear=args["clear"]delargs["containers"]delargs["clear"]Ids=[]ifclear:cli=Tsaotun()cli.send('ps -a --format {{Id}}')ress=cli.recv()ifress:ress=ress.split('\n')ress=[res[0:4]forresinress]forIdinress:Ids.append(Id)args['container']=Idself.client.remove_container(**args)else:forIdincontainers:Ids.append(Id)args['container']=Idself.client.remove_container(**args)self.settings[self.name]='\n'.join(Ids)exceptAPIErrorase:raiseedeffinal(self):returnself.settings[self.name]5LicenceApache License v2.0:LICENSE.6AuthorBoik Su(@qazbnm456) created Tsaotun.