基于python的docker帮助

tsaotun的Python项目详细描述


q:我不明白为什么我需要这个

A:

在传统的方式下,我们会在Docker命令中使用别名。

我开发这个项目的原因是为了鼓励人们在插件中贡献和分享他们的想法和想法,这将使Tsaotun有能力做这些事情。而且,上面的事情只是Tsaotun可以实现的事情之一,你将来也可以加载各种插件。

此外,如果您正在做一些涉及运行容器的项目,tsaotun已经为您提供了更高级别的api。这是另一个有用的功能。

目前,我正在将以前的项目VWGen移到tsaotun的插件中。完成后,每个人都可以加载插件并扩展tsaotun的功能。

Higher level API

Latest version released on PyPiCompatible on LinuxCompatible on MacCompatible on Windows

1   Main features

  • 运行Docker可以在Tsaotun上运行的任何命令
  • 全部用python编写,热爱docker的api
  • 简化自己实现Docker命令行工具的过程
  • 许多插件即将推出

2   Installation (All platforms)

2.1   pip

一种通用的安装方法(适用于windows、mac os x、linux,并且始终提供最新版本)是使用pip

# Make sure we have an up-to-date version of pip and setuptools:
$ pip install --upgrade pip setuptools

$ pip install --upgrade tsaotun

(如果pip安装由于某种原因失败,您可以尝试 easy_install tsaotun作为回退。)

2.2   Docker hub

dockerhub中提取,或者自己构建:

$ docker build -t tsaotun .

请确认我们现在已经安装了最新版本,例如:

$ tsaotun version
Client:
    Version:         0.8.1
    Python version:  2.7.13
    OS/Arch:         Darwin/x86_64

Server:
    Version:         1.13.0-rc7
    API version:     1.25 (minimum version 1.12)
    Go version:      go1.7.3
    Git commit:      48a9e53
    Built:           5 days ago
    OS/Arch:         linux/amd64
    Kernel version:  4.9.3-moby
    Experimental:    True

3   Usage

你好,世界:

$ tsaotun [COMMAND]

概要:

$ tsaotun [-h][--console][--color][--debug][--dry][--host list][--verbose]{version,info,inspect,container,image,network,volume,addon}
          ...

另请参见tsaotun --help

4   Addon

加载项功能正在测试,每个加载项都应该有自己的文件夹,其中包含__init__.py

加载项文件夹结构显示如下:

$HOME
└───Tsaotun
    └───addons
        ├── addon_A - __init__.py, ...
        ├── addon_B - __init__.py, ...
        └───__init__.py

4.1   Best practices (Sample addon to remove “ALL” containers at once, no matter it’s dead or alive)

\u init.py:指定如何重写原始命令

"""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.')",],},]

容器/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]

5   Licence

apache许可证v2.0:LICENSE

6   Author

Boik Su@qazbnm456)创建了tsaotun。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么程序显示空结果?   java应用程序在测试设备上调试时工作正常,但在发布版apk中没有,它没有获得post。来自firebase的类变量   java Android:从主活动按钮确定在listview中选中哪个复选框   在Spring中添加@OneToOne注释时启动ApplicationContext时发生java错误   用JAVA Android实现矩阵计算的最快方法   SpringJava语义有没有更好的编写方法?   java从hashmap中减去两个值后返回最小差值的键?   Java中的静态初始化顺序:Netty 4.0.7的例外   java如何检查用户输入是否为字符串   循环Java计数单词索引   java如何使用以下代码将视频流传输到Android异步Http服务器?   java如何在jtable的所有行中循环   java如何使用maven将unicode插入mysql   java使用安卓加速远程数据检索   java试图模拟麦克风(javax.sound.sampled)   swing SwingWorker从不归还任何东西?(爪哇)   首次在Android Studio上未加载java LibGDX文件   java如何在多个Mysql服务器上设置限制和偏移?   如何防止从java连接到mongodb时登录控制台?