Introduction
Q. Waht is a web application? A. A web (based) application is any program that is accessed over a network connection using HTTP, rather than existing within a device’s memory.
making web apps
- Build your App
- Pack it for shipping
- Host or Run the App
we are going to using a nginx.
Web-apps Problem
Way too many of them and still growing “But it worked on my machine!” issues Faster Updates due to growth of DevOps Abundance of Data Wide use VMs
Container
Containers are an abstraction at the Application layer that packages codes and dependencies together
hypervisor , docker host os picture~~~
Containers … Consumes less storage and memeory Easier and faster to ship If they work on one machine; they work on all machines Cost efficient and easy to sacle Possible to eliminate data loss and downtime
Introducing Docker
Docker is an open platform for developers and system admins to build, ship and run containerized applications.
- Most widely used Containerization platform
- Huge comments:munity support
- Large amount of 3rd party application support
- Works on Windows and Mac too
Dockerfile(build) => DockerImage(ship) => containers(Run)
#Docker Architecture Docker Client = > interaction with client Docker CLI ex.) docker run, docker pull Docker API ex.) client.container.run, client.container.pull
Docker Host => actually performing part
Docker Registry => store docker images
Docker Client Docker Host Docker Registry API calls, Result Images
#Dockerfile A sequential set of instruction for Docker Engine Primary way of interacting with Docker Order of sequence is important! Each instruction creates a layer Layers can be cached and reused by Docker
##Docker file structure
Fundamental Instruction
ARG CODE_VERSION=16.04
FROM ubuntu:${CODE_VERSION}
RUN apt-get update -y
CMD ["bash"]
Configuration Instruction
FROM ubuntu:16.04
LABEL Creator: "Cerulean Canvas"
RUN apt-get update && apt-get install -y curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /home/Codes
ENV USER Cerulean-Canvas
ENV SHELL /bin/bash
ENV LOGNAME Cerulean-Canvas
CMD ["bash"]
Expose Instruction
FROM ubuntu:16.04
RUN apt-get update && apt-get install nginx -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Docker Images
A stack of multiple layers created from Dockerfile Instructions Each layer apart from the top one is R/O The top player is R/W type Recognized by name order Image ID They are pushed to and can be pulled from Docker Hub
docker image inspect img_from
를 통해 image 파일의 설정값을 볼 수 있다.
Container
Running instance of a Docker ImageProvides similar isolation to VMs but lighter … A LOT LIGHTER! Adds writable layer on top of image layers and works on it Can talk to other containers like processes instructions Linux Uses Copy-on-Write
Docker Netweork Driver
Piece of software that enables networking of containers Responsible for invoking a network inside the host or within the cluster Native n/w drivers are shipped with Docker Engine Remote n/w drivers are created and managed by 3rd party vendors or community IP Address Management Drivers provide default subnets if not specified by admin
Docker’s Native Network Driver Overlay Network => Swarm Mode of docker multi host multi container
docker network create –driver bridge my-bridge docker network create –driver bridge –subnet=192.168.0.0/16 –ip-range=192.168.5.0/24 my-bridge-1 docker network ls –filter driver=bridge
Docker Storage
Docker Volume : dedicated directoreis on host’s file system tmpfs : not persistent volume volume : /var/lib/docker/volume/ 의 특정 위치에 저장 non docker 프로세스는 건드릴 수 없다 bind mount : bind mount는 Data가 Host System의 어디에든지 저장이 가능
Docker Compose
Multi container applicatio with single file
version: '3.3'
services:
db:
image: mysql:5.7
container_name: mysql_database
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: word@press
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: abc@123
wordpress:
depends_on:
- db
image: wordpress:latest
container_name: wd_frontend
volumes:
- wordpress_files:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: abc@123
volumes:
wordpress_files:
db_data:
Docker compose command line
docker-compose config –services docker-compose images docker-compose ps docker-compose top docker-compose down docker-compose up
Docker Swarm
A Container Orchestrator is a tool used to provision, schedule and manage containers at large scale over one or more clusters of multiple hosts manager host + worder hosts
To make sure that the Swarm cluster functions properly, at least more than half of the nodes should be working. use docker-machine
Docker GUIL
Kitematic