0% found this document useful (0 votes)
4 views32 pages

Docker: Building and Managing Containers

Uploaded by

idiotmukul3
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)
4 views32 pages

Docker: Building and Managing Containers

Uploaded by

idiotmukul3
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

ONCE UPON A TIME


WE USED TO BUILD ONE LARGE
APPLICATIONS
BUT WE REALIZED THAT BREAKING THEM INTO
COMPONENTS WHICH SERVE ONE FUNCTION ONLY
IS A MUCH BETTER IDEA

AUTH API

FRONTEND BACKEND
QUICKER DEPLOYMENT
LESS DEPENDENCY IN TEAMS
LESS RISK
EASY DEBUGGING
MEANWHILE AT THE
INFRASTRUCTURE
SIDE
WHEN WE HAD ONE BIG
APPLICATION

CentOS
WE WANT SEPARATE ENVIRONMENTS
OR IT DEFEATS THE PURPOSE

AUTH API

FRONTEND BACKEND

CentOS
AND SO WE DIVIDE

AUTH API
CentOS CentOS

FRONTEND BACKEND
CentOS CentOS
BUT IT IS IN THE NATURE OF A DEVELOPER
TO TAKE THIINGS TO A LITTLE EXTREME
CHALLENGES
CHALLENGE #1 : VM OVERHEAD

Usable CPU and


Memory

Operating System
CentOS
VM Overhead

Operating System Usable CPU and Memory


VM Overhead

Operating System Usable CPU and Memory


CHALLENGE #2 : RESOURCE UTILIZATION
CHALLENGE #3 : DEPENDENCIES

Java
java8 Java
ruby9 Java
java8 ruby9
Java

react
Java 10 python
Java 8 react
Java 10 python
Java 9

java8
Java ruby9
Java java8
Java ruby9
Java

react
Java 10 Java 9
python react
Java 10 Java
python
10
LETS TAKE SOME HELP FROM LINUX

CGROUP NAMESPACE
A Linux kernel feature that limits, accounts A Linux kernel feature that creates
for, and isolates the resource usage of a logical boundary amongst processes
collection of processes
CGROUP + NAMESPACE +
=
SHELL

KERNEL

HARDWARE
HARDWARE EMULATION
SHELL

KERNEL

HARDWARE
VIRTUAL MACHINES DOCKER

App1 App2

Bin / Libs Bin / Libs Virtual


machines App1 App2
Containers
Guest OS Guest OS Bin / Libs Bin / Libs

Hypervisor Docker Engine

Host OS Host OS

Infrastructure Infrastructure
java ruby java ruby

react python react python

java ruby java ruby

react python react python


java ruby java ruby

react python react python

java ruby java ruby

react python react python


DOCKER

Container Dockerfile
Docker is an open platform for
developing, shipping, and running
applications.

Docker is a computer program that


performs operating-system-level
Docker virtualization, also known as
“containerization”.

Docker provides the ability to


package and run an application in a
loosely isolated environment called
a container.
Container
• A Docker container is a lightweight, standalone, executable package
of software that includes everything needed to run an application:
• Code
• Runtime
• System tools
• System libraries
• Settings
• Containers are an abstraction at the application layer that packages
code and dependencies together.
• Multiple containers can run on the same machine and share the OS
kernel with other containers.
[Link]

Setup docker on your machine: apt-get install [Link] -y

Checking if docker is installed: docker --version

Know Let’s pull some image from Dockerhub: docker pull <image-name>

your Now list the downloaded docker image: docker images

comman
ds
Let’s run the docker image: docker run –d <image-name>

Check if container is running: docker ps

Let’s stop the running container: docker stop <container-id>


Dockerfile
• A Dockerfile is a text document that contains all the commands a user could call on the command line to
assemble an image.
• Using docker build, users can create an automated build that executes several command-line instructions
in succession to create an image from the Dockerfile

• Commands:
• FROM - The base image for building a new image. This command must be on top of the dockerfile.
• RUN - Used to execute a command during the build process of the docker image.
• ADD/COPY - Copy a file from the host machine to the new docker image.
• ENV - Define an environment variable.
• CMD - Used for executing commands when we build a new layer from the docker image.
• ENTRYPOINT - Define the default command that will be executed when the container is running.
• WORKDIR - This is directive for CMD command to be executed.
• USER - Set the user for the container created with the image.
• VOLUME - Enable access/linked directory between the container and the host machine. ENTRYPOINT [“python3”]
• EXPOSE - Expose a localhost port of the container to external environment.
EXPOSE 8080 USER root
VOLUME /local/dir /container/dirCOPY C:/host/directory
ADD FROM pipENV
install /container/app/directory
RUNpython:3.6.6-alpine
keyFlask
value WORKDIR /app/main
CMD [“java”,”-jar”,”[Link]”] CMD [“[Link]”]
DOCKER DEMO
USE CASE
SA-Logic SA-WebApp SA-Frontend

A python application A Java Web Application A Nginx web server


that performs that handles requests from that serves our
Sentiment Analysis. the frontend. ReactJS static files.
A client application requests the
[Link] (which in turn requests
bundled scripts of ReactJS Spring WebApp returns
User interacting the response
with the
application) to the React triggers
application app. (Which then
requests
represents theWebApp.
to the Spring information to the
user)

Spring WebApp forwards the


requests for sentiment analysis
Python Application calculates to the Python app
the sentiment and returns the
result as a response

You might also like