2015-10-05 282 views
10

我設置了使用泊塢窗,撰寫一個集裝箱堆場。然而,通過運行如何驗證我的docker-compose.yml?

docker-compose up 

我得到一個非常模糊的錯誤消息:

Traceback (most recent call last): 
    File "/usr/local/bin/docker-compose", line 9, in <module> 
    load_entry_point('docker-compose==1.4.2', 'console_scripts', 'docker-compose')() 
    File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 39, in main 
    command.sys_dispatch() 
    File "/usr/local/lib/python2.7/dist-packages/compose/cli/docopt_command.py", line 21, in sys_dispatch 
    self.dispatch(sys.argv[1:], None) 
    File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 27, in dispatch 
    super(Command, self).dispatch(*args, **kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/compose/cli/docopt_command.py", line 24, in dispatch 
    self.perform_command(*self.parse(argv, global_options)) 
    File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 57, in perform_command 
    verbose=options.get('--verbose')) 
    File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 78, in get_project 
    config.load(config_details), 
    File "/usr/local/lib/python2.7/dist-packages/compose/config.py", line 138, in load 
    for service_name, service_dict in list(dictionary.items()): 
AttributeError: 'NoneType' object has no attribute 'items' 

如何調試?我已檢查yml是否有效,但它不起作用。

回答

20

我忘了救我docker-compose.yml,所以它是空的。

我穿過溶液中this issue about making the error message better其描述行爲絆倒。如果沒有docker-compose.yml存在於所有

人們得到一個不錯的消息:

Can't find a suitable configuration file in this directory or any parent. Are you in the right directory? 
Supported filenames: docker-compose.yml, docker-compose.yaml, fig.yml, fig.yaml 

這是anounced on the docker-compose's issue名單會有在upcomming 1.5版本一個更好的錯誤消息:

Top level object needs to be a dictionary. Check your .yml file that 
you have defined a service at the top level. 

隨着版本1.7.1的錯誤消息指出該文件是空的讀取:

ERROR: Top level object in './docker-compose.yml' needs to be an 
object not '<type 'NoneType'>'. 
+7

神聖的廢話,我不能相信我忘了打保存太。 –

+0

@CodyReichert考慮升級搬運工-撰寫,用於更可讀的錯誤消息。 – k0pernikus

+1

大聲笑。也沒有保存。很好地完成了這個答案。徹底。 –