0% found this document useful (0 votes)
178 views264 pages

Kernal: Redis-Server Redis-Cli Redis-Server Redis-Cli

The document summarizes how Docker containers and images work. Docker containers isolate applications from each other and the underlying host machine. Dockerfiles are used to build custom images which bundle code and dependencies. Images act as templates for containers which run the specified commands. Compose files define multi-container applications and their dependencies.

Uploaded by

Praveen Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views264 pages

Kernal: Redis-Server Redis-Cli Redis-Server Redis-Cli

The document summarizes how Docker containers and images work. Docker containers isolate applications from each other and the underlying host machine. Dockerfiles are used to build custom images which bundle code and dependencies. Images act as templates for containers which run the specified commands. Compose files define multi-container applications and their dependencies.

Uploaded by

Praveen Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 264

Containerntainer Containerntainer

A B
Redis-server Redis-cli Redis-server Redis-cli

Kernal

RAM CPU RAM CPU

HDD Segment for this Process HDD Segment for this Process

docker exec -it <Container ID> <App Command>


Redis-cli

STDIN STDOUT STDERR

YOU TYPE OUT ON TERMINAL

YOUR TERMINAL
BUILDING CUSTOM IMAGES
redis

FS Snapshot Startup Command

redis >>run blabla

Dockerfile Docker Client Docker Server Usable Image


Creating a Docker file

Specify a Base Image FROM alpine

Run Some Commands to install


RUN apk add --update redis
additional programs

Specify a Command to run on CMD ["redis-server"]


Container startup
Creating a Docker file

Specify a Base Image FROM alpine

Run Some Commands to install


RUN apk add --update redis
additional programs

Specify a Command to run on CMD ["redis-server"]


Container startup
Instruction Telling Docker Argument to the
Server What to Do Instruction

FROM alpine

RUN apk add --update redis

CMD ["redis-server"]
Writing a Telling someone to Install
Docker file chrome without OS
Install OS

Start Default Browser

Open Google

Download Installer of Chrome

Install Chrome

Run Chrome
Containerntainer
A

redis-server FROM alpine

RUN apk add --update redis

Kernal CMD ["redis-server"]

RAM CPU

Apline Image

FS Snapshot Startup Command

>>run redis-server
Dev etc redis
Apline Image

FROM alpine
FS Snapshot Startup Command

>>run redis-server
Dev etc redis

Apline Image
Apline Image
RUN apk add --update redis
FS Snapshot Startup Command
FS Snapshot Startup Command
>>run redis-server
RUN apk add --update dcc Dev etc redis
>>run redis-server
Dev etc gcc

Apline Image
CMD ["redis-server"]

FS Snapshot Startup Command

>>run redis-server
Dev etc redis
Tagging an Image

docker build -t coding4startups/redis:latest .


Containerntainer
A

Node Js

Kernal

RAM CPU

NodeJs App
Create a Node js App

Create a docker file

Build Image from DOckerfile

Run Image as COntainer

Connect to web app from a Browser


Install
npm install
Dependencies

Assuming npm
Node JS App
is installed

Start Server npm start


Creating a Docker file

Specify a Base Image FROM alpine


FROM alpine
Run Some Commands
to install additional RUN apk add
programs RUN npm install
--update redis
Specify a Command to
run on Container
CMD [“npm“,”start”]
startup CMD ["redis-
server"]
FROM node:alpine npm install

RUN npm install


Kernal
Kernal

CMD [“npm“,”start”]
RAM CPU

Node Image
Dev etc Node:alpine
FS Snapshot Startup Command

>>run Node
Dev etc Node:alpine
REST of THE HDD RESOURCES
Copy ./ ./WORKDIR
Containerntainer
A

Node Js

Kernal

8078

8079 Network
Network
8080
8080
docker run -p 8080 : 8080 <img Name>
WORKDIR /usr/app
SECTION-5
WORKDIR
App OverView

Node
Number of Visits = 10 App

Redis
Number of Visits = 10 Node App

Redis = 10
OSE
M P
R CO
C KE Separate CLI that Get Installed with Docker
DO

Used to Start Up Multiple Containers at the Same Time

Automates some of the arguments we were passing to


‘DOCKER RUN’
docker run -p 8080 : 8080 <img Name>
docker build -t coding4startups/redis:latest .

DOCKER COMPOSE.YML

DOCKER COMPOSE CLI


DOCKER-COMPOSE.YML

HERE ARE THE CONTAINER I WANT CREATED

REDIS-SERVER

USE REDIS IMAGE

NODE APP

MAKE USING
DOCKER FILE
MAP PORT
8080:8080
docker run image docker-compose up

docker build . docker-compose up --build


Never Attempt to Restart this container
“no”
if it stops or crashes
If Container stops for any reason always
always
attempt to restart it
If Container stops for any reason always
On Failure
attempt to restart it

Unless-
Always restart unless I forcibly stop it
stopped
CREATING A
PRODUCTION GRADE
WORK FLOW
Development

Testing

Deployment
Github Repo
Feature Master

.travis.yml Travis CI

AWS
Hosting
Dev Push to Git Hub
Create Pull Request

Code Pushed to Travis CI


Test
and Tested

Deploy to AWS Elastic


Prod Beanstalk
PC Docker Container
FrontEnd /app
files ref
folders ref
ref
docker run -p 8080 : 8080 <img Name>

-v/app/node_modules -v $(PWD):/app
Test Container Web Container
npm run test npm run start
in out stderr in out stderr
Prod Env

Web Container

Index.html
nginx
Main.js
Use Node:alpine

Copy Packages. jason

Install Dependencies

Run npm Build

Start Nginx
Use Node:alpine USE nginx

Copy Packages. jason

Install Dependencies COPY OVER RESULT OF NPM BUILD

Run npm Build

Start Nginx
GitHub Free

Travis CI Free

AWS Credit Card


Create GitHub Repo

Create Local Git Repo

Connect Both Local and Git Repo

Push all the work to Remote


Tell Travis we need a copy of Docker Running

Build Our Image using Dockerfile.dev

Tell Travis how to run our test suit

Tell travis how to deploy our code to AWS


Number of
VM Running Docker
Visits = 10000

Load Docker Container


Balancer App

VM Running Docker

Docker Container
App
Copy over package.json

Run ‘npm install’

Copy Over everything else

Docker Compose should set up a volume to share


files
COMPOSE

postgress
What image to use

redis
What image to use

SERVER

Specify build

Specify volumes
Specufy env variables
DEVELOPMENT

Worker

React Server

Redis
NginX

Express Server
postgres
Tell nginx that there is an upstream
server at client:3000

Tell nginx that there is an upstream


server at server:5000

Default.conf
Listen on Port 80

For ‘/’ request route them to client


upstream

For ‘/api’ request route them to server


upstream
Push Code on Github

Travis pull repo

T CI builds Image, test code

T CI builds PROD Image

Travis Pushed it to DockerHub

Travis Pushed it to AWS EB

EB pulls images from DockerHub and Deploys


DEVELOPMENT

Worker

React Server

Redis
NginX

Express Server
postgres
Automatically and maintains Redis instance

Scalable super easy

Elastic Cache Builtin Log and Maintable

Better Security

Easier to Migrate
Automatically and maintains Redis instance

Scalable super easy

AWS Relational
Database Builtin Log and Maintable

Better Security

Easier to Migrate

Rollbacks backaup
Elastic Cache

AEB

AWS Relational
Database

You might also like