Introduction
Another article concerning about error message appearance when running docker-compose command. Basically, this article will show why the error message appear upon the execution of the ‘docker-compose’ command. The following is the actual execution of the command in Microsoft Windows :
C:\repository\docker\wordpress>docker-compose up -d ERROR: Top level object in '.\docker-compose.yml' needs to be an object not '<class 'NoneType'>'. C:\repository\docker\wordpress>
How to Solve Error Message ERROR: Top level object in ‘.\docker-compose.yml’ needs to be an object not ‘<class ‘NoneType’>’
So, in order to keep it short, the following are the steps to solve the above error message :
-
First of all, the most important thing is to just check something. In this context, it is checking the availability of a file with the name of ‘docker-compose.yml’. It is an important file which is basically a requirement for running the ‘docker-compose up -d’ command. So, just run a command in order to check the content of the directory where the command execution occur :
C:\repository\docker\wordpress>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\docker\wordpress 05/28/2022 08:35 AM <DIR> . 05/25/2022 01:27 PM <DIR> .. 05/28/2022 08:35 AM 0 docker-compose.yml 3 File(s) 691 bytes 3 Dir(s) 186,083,102,720 bytes free C:\repository\docker\wordpress>
-
Apparently, there is already a file with the name of ‘docker-compose.yml’. The following step is to check the content of the ‘docker-compose.yml’ file. Unfortunately, the content is empty. That is why it cause the error to appear. So, in order to handle by make the error message disapper, just fill the ‘docker-composer.yml’. Actually, the simplest content will be just define the version. Just add the following line :
version: '3.3'
Just adjust the version number with the one available in the operating system.
-
Run the command once more. Although it is a success for handling the problem by removing error message appearance, it still just do nothing as follows :
C:\repository\docker\wordpress>docker-compose up -d C:\repository\docker\wordpress>