Docker 17
引擎: 管理员指南 | Engine: Admin Guide

使用Puppet(引擎) | Using Puppet (Engine)

使用木偶

意,这是社区提供的安装路径。唯一official安装使用乌本图安装路径。这个版本有时可能过时了。

所需

要使用本指南,您将需要从木偶实验室...

该模块目前也使用正式的PPA,因此只适用于Ubuntu。

安装

模块可在木偶锻造并可使用内置模块工具安装。

$ puppet module install garethr/docker

它也可以在GitHub如果你想下载源代码的话。

使用

该模块提供了一个用于安装Docker的傀儡类和两个用于管理映像和容器的定义类型。

安装

include 'docker'

图像

下一步可能是安装Docker映像。为此,我们有一个定义的类型,可以这样使用:

docker::image { 'ubuntu': }

这相当于运行:

$ docker pull ubuntu

请注意,只有当该名称的图像不存在时才会下载。这是下载一个大的二进制文件,所以在第一次运行可能需要一段时间。由于这个原因,这个定义关闭了EXEC类型的默认5分钟超时。请注意,您还可以删除不再需要的图像:

docker::image { 'ubuntu': ensure => 'absent', }

集装箱

现在,您可以在由Docker管理的容器中运行命令。

docker::run { 'helloworld': image => 'ubuntu', command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"', }

这相当于运行以下命令,但在upstart下:

$ docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"

Run还包含一些可选参数:

docker::run { 'helloworld': image => 'ubuntu', command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"', ports => ['4444', '4555'], volumes => ['/var/lib/couchdb', '/var/log'], volumes_from => '6446ea52fbc9', memory_limit => 10485760, # bytes username => 'example', hostname => 'example.com', env => ['FOO=BAR', 'FOO2=BAR2'], dns => ['8.8.8.8', '8.8.4.4'], }

*ports,,,env,,,dns,和volumes属性可以用单个字符串设置,也可以像上面那样使用一个值数组来设置。

木偶安装使用码头工人文献资料