Introduction
This is an article where the main focus is just to discuss about how to solve a specific error message. In this context, it is an error message which is appearing upon the execution of ‘docker-compose’ command. Actually, in order to execute docker-compose command, there must a certain requirement so the command itself is possible to run properly. It is the need of a file with the name of ‘docker-compose.yml’. It is a yaml file which has the extension of ‘*.yml’. Furthermore, it must has a name of ‘docker-compose’. Not only the existence of the file, but also the content must be in a correct form. So, the following is the actual execution of the ‘docker-compose’ command using the ‘docker-compose.yml’ in order to describe how to build the docker image :
C:\repository\docker\docker-image-build-with-docker-compose>docker-compose build version must be a string C:\repository\docker\docker-image-build-with-docker-compose>
Before going on further, the following is the actual content of the ‘docker-compose.yml’ file for consideration :
version: 3.3
How to Solve Error Message version must be a string when running ‘docker-compose build’ Command
So, how to solve the error message exist as in the previous part ?. Well, the answer is very simple. Furthermore, the answer for solving the error message actually exist as part of the error message. It is hinting the solution for solving it. In other words, just perform the solution according to the hint exist in the error message. It is obvious, in order to solve the problem, just change the value of the version. In the above definition, the value of the version is in a numeric version. So, in order to change it into a string format, just add quotes. Specifically, just enclose all the value inside quotes. A single quote is enough for the usage in order to change the value from numeric to a string format. In that case, the following is the revision of the above declaration of the version :
version: '3.3'
Re-run the command, if there is no more error appear, it will just run properly without having any of the previous error messages occurr. But it will not have any output whatsoever. Since it is only declaring a version’s definition.