2016-09-27 88 views
1

我是新來的碼頭工人,試圖使用廚師在碼頭上實現碼頭工人7.1 下面是我爲安裝,拉動centos鏡像和創建容器而寫的基本代碼。無法啓動容器

所有3個任務都成功執行。由於容器處於停止模式,我嘗試通過輸入docker start containerid來手動啓動。當我檢查docker ps時,我發現容器未啓動。我嘗試了幾次,但無法啓動容器。

泊塢代碼中使用廚師

docker_service 'default' do 
    action [:create, :start] 
end 

docker_image 'centos' do 
    action :pull 
end 

docker_container 'check2' do 
    repo 'centos' 
    action :create 
end 

泊塢窗信息:

Containers: 6 
Running: 1 
Paused: 0 
Stopped: 5 
Images: 3 
Server Version: 1.12.1 
Storage Driver: devicemapper 
Pool Name: docker-8:1-523814-pool 
Pool Blocksize: 65.54 kB 
Base Device Size: 10.74 GB 
Backing Filesystem: xfs 
Data file: /dev/loop0 
Metadata file: /dev/loop1 
Data Space Used: 441.3 MB 
Data Space Total: 107.4 GB 
Data Space Available: 28.08 GB 
Metadata Space Used: 1.159 MB 
Metadata Space Total: 2.147 GB 
Metadata Space Available: 2.146 GB 
Thin Pool Minimum Free Space: 10.74 GB 
Udev Sync Supported: true 
Deferred Removal Enabled: false 
Deferred Deletion Enabled: false 
Deferred Deleted Device Count: 0 
Data loop file: /var/lib/docker/devicemapper/devicemapper/data 
WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device. 
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata 
Library Version: 1.02.107-RHEL7 (2016-06-09) 
Logging Driver: json-file 
Cgroup Driver: cgroupfs 
Plugins: 
Volume: local 
Network: null host bridge overlay 
Swarm: inactive 
Runtimes: runc 
Default Runtime: runc 
Security Options: seccomp 
Kernel Version: 3.10.0-229.4.2.el7.x86_64 
Operating System: CentOS Linux 7 (Core) 
OSType: linux 
Architecture: x86_64 
CPUs: 4 
Total Memory: 6.807 GiB 
ID: R24R:ORHY:XJQW:2HNI:U5TV:UGF7:B7VX:P6Z6:UHSR:YIMR:VGJT:4URU 
Docker Root Dir: /var/lib/docker 
Debug Mode (client): false 
Debug Mode (server): false 
Registry: https://index.docker.io/v1/ 
WARNING: bridge-nf-call-iptables is disabled 
WARNING: bridge-nf-call-ip6tables is disabled 
Insecure Registries: 
127.0.0.0/8 

請你幫我

+0

小心使用devicemapper的循環文件運行的東西! http://stackoverflow.com/questions/37672018/clean-docker-environment-devicemapper – user1933131

回答

2

默認情況下,centos圖像將運行/bin/bash將立即退出無終端(-t)和標準輸入(-i)可用。

嘗試在容器

docker_container 'check2' do 
    repo 'centos' 
    command 'top -b -d 5' 
end 
+0

謝謝,它的工作。作爲一名初學者,我有以下疑問,請您就以下方面給我建議1)在廚師中實施碼頭工人的最佳做法是什麼(我可以在廚師中使用碼頭文件或食譜來定義任務)2)是否需要引導每個容器在裏面做任務嗎? 3)我可以得到很好的材料或鏈接,以簡單閱讀使用廚師的碼頭工人。非常感謝 – kumar

+0

@kumar這似乎是一個很好的「廚師和碼頭工人」問題添加到網站。 – Matt

+0

我的困惑是關於下一步做什麼來引導容器。現在我寫了一些配方,將安裝docker並在廚師節點上創建一個容器。我的目標是做容器bootstraping,以便我可以在裏面安裝jenkins。我經歷了許多網站,但沒有得到明確。請指教 – kumar