When ever we run the docker compose command then it will find the file docker-compose.yml file, If it will not found then it will give the error
[root@ip-172-31-95-65 ~]# mv docker-compose.yml docker-compose2.yml
[root@ip-172-31-95-65 ~]# ls
docker-compose2.yml
[root@ip-172-31-95-65 ~]# docker-compose up
ERROR:
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
[root@ip-172-31-95-65 ~]#
[root@ip-172-31-95-65 ~]# mv docker-compose.yml docker-compose2.yml
[root@ip-172-31-95-65 ~]# ls
docker-compose2.yml
[root@ip-172-31-95-65 ~]# docker-compose up
ERROR:
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
[root@ip-172-31-95-65 ~]#
If you want to give any other name in place of docker-compose.yml then
[root@ip-172-31-95-65 ~]# docker-compose -f docker-compose2.yml up -d
root_webapp1_1 is up-to-date
root_webapp2_1 is up-to-date
In this case it will not look for default file(docker-compose.yml) in place of it what ever file you will give it will take that one only.
[root@ip-172-31-95-65 ~]# docker-compose -f docker-compose2.yml down
Stopping root_webapp2_1 ... done
Stopping root_webapp1_1 ... done
Removing root_webapp2_1 ... done
Removing root_webapp1_1 ... done
Removing network root_default
[root@ip-172-31-95-65 ~]#
------------------------------------------------------------------------------------------
Docker compose will take json format code also you can convert yml to json in below link
[root@ip-172-31-95-65 ~]# vi docker-compose.json
[root@ip-172-31-95-65 ~]# cat docker-compose.json
{
"version": "3",
"services": {
"webapp1": {
"image": "nginx",
"ports": [
"8000:80"
]
},
"webapp2": {
"image": "nginx",
"ports": [
"8001:80"
]
}
}
}
[root@ip-172-31-95-65 ~]# docker-compose -f docker-compose.json up -d
Creating network "root_default" with the default driver
Creating root_webapp1_1 ... done
Creating root_webapp2_1 ... done
Hi,
ReplyDeletei request you to visit YAML TO JSON CONVERTER . That contain so much YAML Convert Tool .
Validate,Beautify,minify as well as csv,xml,json,base64 converter from yaml.
Regards,
Peter
Hey checkout this https://www.yamlonline.com/
ReplyDeleteIt's a nice tools for YAML to JSON try it!!
Hey checkout this
ReplyDeletehttps://www.yamlonline.com/
It's a nice tools for YAML to JSON try it!!