我正在尝试在我的 Mac(OS X Mavericks)上使用测试厨房(附带 ChefDK 并安装了 docker-api 驱动程序)在远程服务器上创建一个 docker 实例,但我似乎在最后一步几乎失败了:
stardust:test_kitchen rilindo$ kitchen create
-----> Starting Kitchen (v1.2.1)
-----> Creating <default-centos-64>...
Step 0 : FROM centos:centos6
---> 68edf809afe7
Step 1 : RUN yum clean all
---> Using cache
---> 79fd0e4588de
Step 2 : RUN yum install -y sudo openssh-server openssh-clients curl
---> Using cache
---> 131f54051dc4
Step 3 : RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
---> Using cache
---> d05a99414427
Step 4 : RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
---> Using cache
---> 53636accc8b7
Step 5 : RUN mkdir -p /var/run/sshd
---> Using cache
---> fa875c2e9f1a
Step 6 : RUN useradd -d /home/kitchen -m -s /bin/bash kitchen
---> Using cache
---> 962000c5929d
Step 7 : RUN echo kitchen:kitchen | chpasswd
---> Using cache
---> f22dcbca6292
Step 8 : RUN echo 'kitchen ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
---> Using cache
---> cb9d8b95eb33
Successfully built cb9d8b95eb33
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [undefined method `[]' for nil:NilClass]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
尝试创建容器端口时似乎失败了:
stardust:test_kitchen rilindo$ tail -30 .kitchen/logs/kitchen.log
I, [2014-10-09T23:46:59.460656 #1112] INFO -- Kitchen: -----> Starting Kitchen (v1.2.1)
I, [2014-10-09T23:46:59.525462 #1112] INFO -- Kitchen: -----> Destroying <default-centos-64>...
I, [2014-10-09T23:47:02.720005 #1112] INFO -- Kitchen: -----> Kitchen is finished. (0m3.26s)
I, [2014-10-09T23:48:49.778602 #1118] INFO -- Kitchen: -----> Starting Kitchen (v1.2.1)
I, [2014-10-09T23:48:49.842909 #1118] INFO -- Kitchen: -----> Creating <default-centos-64>...
E, [2014-10-09T23:48:52.826223 #1118] ERROR -- Kitchen: ------Exception-------
E, [2014-10-09T23:48:52.826280 #1118] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2014-10-09T23:48:52.826322 #1118] ERROR -- Kitchen: Message: Failed to complete #create action: [undefined method `[]' for nil:NilClass]
E, [2014-10-09T23:48:52.826363 #1118] ERROR -- Kitchen: ---Nested Exception---
E, [2014-10-09T23:48:52.826403 #1118] ERROR -- Kitchen: Class: NoMethodError
E, [2014-10-09T23:48:52.826442 #1118] ERROR -- Kitchen: Message: undefined method `[]' for nil:NilClass
E, [2014-10-09T23:48:52.826481 #1118] ERROR -- Kitchen: ------Backtrace-------
E, [2014-10-09T23:48:52.826520 #1118] ERROR -- Kitchen: /Users/rilindo/.chefdk/gem/ruby/2.1.0/gems/kitchen-docker-api-0.4.0/lib/kitchen/driver/docker.rb:228:in `container_ssh_port'
E, [2014-10-09T23:48:52.826560 #1118] ERROR -- Kitchen: /Users/rilindo/.chefdk/gem/ruby/2.1.0/gems/kitchen-docker-api-0.4.0/lib/kitchen/driver/docker.rb:82:in `create'
E, [2014-10-09T23:48:52.826600 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:273:in `public_send'
E, [2014-10-09T23:48:52.826641 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:273:in `block in perform_action'
E, [2014-10-09T23:48:52.826681 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:308:in `call'
E, [2014-10-09T23:48:52.826760 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:308:in `synchronize_or_call'
E, [2014-10-09T23:48:52.826802 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:283:in `block in action'
E, [2014-10-09T23:48:52.826842 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
E, [2014-10-09T23:48:52.826882 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:282:in `action'
E, [2014-10-09T23:48:52.826921 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:273:in `perform_action'
E, [2014-10-09T23:48:52.826961 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:252:in `create_action'
E, [2014-10-09T23:48:52.827001 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:246:in `block in transition_to'
E, [2014-10-09T23:48:52.827041 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:245:in `each'
E, [2014-10-09T23:48:52.827081 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:245:in `transition_to'
E, [2014-10-09T23:48:52.827149 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/instance.rb:108:in `create'
E, [2014-10-09T23:48:52.827189 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/command.rb:109:in `public_send'
E, [2014-10-09T23:48:52.827229 #1118] ERROR -- Kitchen: /opt/chefdk/embedded/apps/test-kitchen/lib/kitchen/command.rb:109:in `block (2 levels) in run_action'
E, [2014-10-09T23:48:52.827269 #1118] ERROR -- Kitchen: ----------------------
我不确定问题是否在于我的 .kitchen.yaml 中的端口是否正确转发。当然,这可能是一个完全不同的问题:
---
driver:
name: docker
socket: tcp://111.222.333.444:4243
provisioner:
name: chef_solo
platforms:
- name: centos-6.4
driver_config:
image: centos:centos6
platform: centos
forward:
- 22:2222
suites:
- name: default
run_list:
attributes:
我正在唱 adnichols/kitchen-docker-api 驱动程序,顺便说一句。