?
This document uses PHP Chinese website manual Release
注請(qǐng)注意,這是社區(qū)提供的安裝路徑。唯一
official
安裝使用烏本圖安裝路徑。這個(gè)版本有時(shí)可能過時(shí)了。
要使用本指南,您將需要從木偶實(shí)驗(yàn)室...
該模塊目前也使用正式的PPA,因此只適用于Ubuntu。
模塊可在木偶鍛造并可使用內(nèi)置模塊工具安裝。
$ puppet module install garethr/docker
它也可以在GitHub如果你想下載源代碼的話。
該模塊提供了一個(gè)用于安裝Docker的傀儡類和兩個(gè)用于管理映像和容器的定義類型。
include 'docker'
下一步可能是安裝Docker映像。為此,我們有一個(gè)定義的類型,可以這樣使用:
docker::image { 'ubuntu': }
這相當(dāng)于運(yùn)行:
$ docker pull ubuntu
請(qǐng)注意,只有當(dāng)該名稱的圖像不存在時(shí)才會(huì)下載。這是下載一個(gè)大的二進(jìn)制文件,所以在第一次運(yùn)行可能需要一段時(shí)間。由于這個(gè)原因,這個(gè)定義關(guān)閉了EXEC類型的默認(rèn)5分鐘超時(shí)。請(qǐng)注意,您還可以刪除不再需要的圖像:
docker::image { 'ubuntu': ensure => 'absent',}
現(xiàn)在,您可以在由Docker管理的容器中運(yùn)行命令。
docker::run { 'helloworld': image => 'ubuntu', command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',}
這相當(dāng)于運(yùn)行以下命令,但在upstart下:
$ docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
Run還包含一些可選參數(shù):
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
屬性可以用單個(gè)字符串設(shè)置,也可以像上面那樣使用一個(gè)值數(shù)組來設(shè)置。