I am setting up a container stack using docker-compose. Yet by running
docker-compose up
I get a rather cryptic error message:
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'
How to debug? I have checked that the yml is valid, yet it doesn't work.
The Compose file is a YAML file defining services, networks and volumes. The default path for a Compose file is ./docker-compose.yml .
The operating-system independent way to check whether Docker is running is to ask Docker, using the docker info command. You can also use operating system utilities, such as sudo systemctl is-active docker or sudo status docker or sudo service docker status , or checking the service status using Windows utilities.
I forgot to save my docker-compose.yml
, so it was empty.
I stumbled across the solution in this issue about making the error message better which was describing the behavior.
One gets a nice message if no docker-compose.yml
exists at all:
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
It was anounced on the docker-compose's issue list that there will be a nicer error message in the upcomming 1.5 release:
Top level object needs to be a dictionary. Check your .yml file that you have defined a service at the top level.
As of version 1.7.1 the error message indicating that your file is empty reads:
ERROR: Top level object in './docker-compose.yml' needs to be an object not '<type 'NoneType'>'.
Given the latest versions, the error message is very straightforward:
$ docker -v
Docker version 19.03.13, build 4484c46d9d
$ docker build .
failed to solve with frontend dockerfile.v0: failed to create LLB definition: the Dockerfile cannot be empty
So for ease of use, consider upgrading your docker engine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With