YAML/JSON
Refer Here for yaml/json tutorial
JSON files generally have extension of .json and yaml files have extension of .yaml or .yml
Data in json/yaml is written in form of name/value pairs
<name>: <value>
scalar
number
boolean
text
complex
list/array
map/object
movie: "Wakanda forever"
yaml:
<name>: <value> ["<value>"]
movie: Wakanda forever
json
"name":"value"
"movie":"Wakanda forever"
price: 350.98
yaml:
<name>: <value>
price: 350
json:
"<name>": <value>
"price": 350
is3D: true
yaml:
<name>: <value> [true/false/yes/no]
is3D: yes
json:
"<name>": <value> [true/false]
"is3D": true
Complex – list
json:
Complex – map/object
syntax: {"<name1>": <value1>,.., "<namen>": <valuen> }
Example – json:
{
"name": "Wakanda Forever",
"price": 350,
"is3D": true,
"actors": ["Wright", "Jordan", "Angela"]
}
---
name: Wakanda Forever
price: 350
is3D: yes
actors:
- Wright
- Jordan
- Angela
{
"movies": [
{
"name": "Wakanda Forever",
"price": 350,
"is3D": true,
"actors": ["Wright", "Jordan", "Angela"]
},
{
"name": "Kantara",
"price": 350,
"is3D": false,
"actors": ["Rishab Shetty", "Kishore", "Achyut"]
}
],
"places": [
{
"name": "vizag",
"spots": [ "RK Beach", "Rushi konda" ]
},
{
"name": "Vijayawada",
"spots": ["Kanaka durga temple", "Krishna river"]
}
]
}
---
movies:
- name: Wakanda forever
price: 350
is3D: yes
actors:
- Wright
- Jordan
- Angela
- name: Kantara
price: 350
is3D: no
actors:
- Rishab
- Kishore
- Achyut
places:
- name: Vizag
spots:
- RK Beach
- Rushi konda
- name: Vijayawada
spots:
- Kanaka durga temple
- Krishna River
In docker compose we create a file docker-compose.yml
where we represent the multi container configuration as per our needs.
Generally docker-compose is used for running a full system in developer environments.
Docker-compose installation:
Install docker
On mac and windows once we install docker, docker-compose is part of the installation, so no need for any extra steps
on linux machines we need to install docker-compose separtely
For docker-compose on linux instances Refer Here
The older versions the docker compose had docker-compose
. Now docker compose is a plugin to docker, so it behaves like sub command (just like docker network, docker volume)
Refer Here for the specification of the docker compose
Refer Here for the latest yaml reference
Refer Here for service configuration reference
Create a simple docker compose file to run a nginx container
Refer Here for our first compose file with nginx container running on port 80 exposed to port 8081
When we performed up docker compose has created a network
lets destroy docker compose down
Lets make changes in the docker compose file to create the network with the specifications provided by us.
Refer Here for the network configuration
Refer Here for the changes to add our own bridge network
Lets add one more container which is mysql
docker container run -d --name mysql -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=test -e MYSQL_USER=directdevops -e MYSQL_PASSWORD=directdevops mysql:5.6
Like this: Like Loading...