YAML (a recursive acronym for "YAML Ain't Markup Language") is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted.
YAML targets many of the same communications applications as Extensible Markup Language (XML) but has a minimal syntax which intentionally differs from SGML.
YAML is case sensitive
scalars (strings / numbers)
sequences (arrays / lists)
mappings (hashes / dictionaries)
They store single value
integer: 25
string: "25"
float: 25.0
boolean: true
They store single value
integer: 25
string: "25"
float: 25.0
boolean: true
Note:
Yaml is supporting single ' or double " quotation marks. Double quotation marks allow you to use escapings to represent ASCII and Unicode characters.
aka your old friend list
- Cat
- Dog
- Goldfish
-
- Cat
- Dog
- Goldfish
-
- Python
- Lion
- Tiger
One dimensional
Multi dimensional
we can do also inline sequences
npcflag: [GOSSIP, VENDOR]
most probably you have seen dictionary
animal: pets
we can assign sequence to the mapping
units:
- Footman
- Grunt
- Knight
- Ogre
or use complex keys
? ["Tower", "Tier 1 Unit"]
: "Gremlin"
they are special case of mapping
set:
? item1
? item2
? item3
they are special case of mapping
-
name: Mark McGwire
points: 65
grade: "A"
-
name: Sammy Sosa
points: 63
grade: "B"
- [name , hr, avg ]
- [Mark McGwire, 65, 0.278]
- [Sammy Sosa , 63, 0.288]
Mark McGwire: {hr: 65, avg: 0.278}
Sammy Sosa: {
hr: 63,
avg: 0.288
}
---
hr:
- Mark McGwire
# Following node labeled SS
- &SS Sammy Sosa
rbi:
- *SS # Subsequent occurrence
- Ken Griffey
When you want avoid duplicities. It is pointer and reference.
---
invoice: 34843
date : 2001-01-23
bill-to: &id001
given : Chris
family : Dumars
address:
lines: |
458 Walkman Dr.
Suite #292
city : Royal Oak
state : MI
postal : 48046
ship-to: *id001
product:
- sku : BL394D
quantity : 4
description : Basketball
price : 450.00
- sku : BL4438H
quantity : 1
description : Super Hoop
price : 2392.00
tax : 251.42
total: 4443.52
comments:
Late afternoon is best.
Backup contact is Nancy
Billsmer @ 338-4338.
Pluto is a planet: false
Do we assign string or boolean here?
Pluto is a planet: !!bool false
Like this it is clear
- true # boolean
- "true" # string, because it's quoted
- !!str true # string, because of !!str
- !!bool "true" # boolean, because of !!bool
HTTP
Client
Server
Browser
DNS Server
CDN
Proxy
App Server 1
App Server 2
App Server 3
Database
Cache (eg. Redis)
Your infrasturcture
1.
2.
3.
Hardware
Hardware
OS
App
App
Hypervisor
OS
OS
App
App
Automates the deployment of software applications inside containers by providing an additional layer of abstraction and automation of OS-level virtualization.
The industry standard today is to use Virtual Machines (VMs) to run software applications. VMs run applications inside a guest Operating System, which runs on virtual hardware powered by the server’s host OS
VMs are great at providing full process isolation for applications: there are very few ways a problem in the host operating system can affect the software running in the guest operating system, and vice-versa. But this isolation comes at great cost — the computational overhead spent virtualizing hardware for a guest OS to use is substantial.
Containers take a different approach: by leveraging the low-level mechanics of the host operating system, containers provide most of the isolation of virtual machines at a fraction of the computing power.
They have their own user space but share host's kernel
You have the same environment on deployment machines as on dev machines. No more works on my machine
You can utilize you machines much more
You define your infrastructure in easy readable text format. You can version it!
Install Docker for Desktop (Windows and Mac). Windows users need Pro version. It is available to you from our faculty.
docker pull helloworld
You must pull image from Docker Hub
Is that image now available on my machine?
docker images
docker run helloworld
Ok, now I can run it
BTW if it is not pulled, it will be pulled when runned.
docker ps
docker ps -a
How to check what images are running?
Sometimes we must cleanup
docker kill container_id # kills running container
docker rm container_id # remove cotainer image from your machine
docker run -p 8888:80 containerName
Often you must map ports
Or you can run deamon
docker run -d --name nodeapp -p 8888:5000 mywebsite/nodeapp
When you want to create your own image with running system and some application, your create Dockerfile (recommended name) and build it.
FROM node:13.10.1-alpine3.11
After creating file specify base image
Next time to define what should happen.
Like defining work directory.
WORKDIR /usr/src/website
COPY . .
Copy files to container
And run some custom commands
In this stage you have application build.
RUN npm install
RUN npm run build
Expose port to outside:
EXPOSE 5000
CMD [“node”, “./“build/index.js]
And setup run command
FROM node:13.10.1-alpine3.11
WORKDIR /usr/src/website
COPY . .
RUN npm install
RUN npm run build
EXPOSE 5000
CMD [“node”, “./“build/index.js]
docker build -t mywebsite/nodeapp .
Docker Compose helps you setup multiple containers at once. Let’s say you want to have a web server, database, and application running. You would have to write lot of Shell code without Compose.
Compose offers simple way to define such architecture in human friendly way.
Start by creating docker-compose.yml (or any other yml file)
Yes, it's YAML file!
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
docker stack deploy -c docker-compose.yml wordpress
# or
docker-compose -f docker-compose.yml up