You are on page 1of 23

Dockerize Your Project!

Improve your project development workflow with


docker and docker-compose

git/twitter @imrenagi
Docker Community Leader, Indonesia
Docker Indonesia
(https://www.meetup.com/Docker-Indonesia/)

Upcoming Meetup:

1. March 7th, 2018, 6.30pm-9pm @Traveloka


2. March 28th, 2018, 6.30pm-9pm @Gojek

Interested to be the next speaker or venue sponsor??


Reach me at @imrenagi / imre.nagi2812@gmail.com
Outline
Docker Basic Demo & Hands On
What is Docker / What is Docker Not Develop multi-service app (tweet live
Basic Docker Commands sentiment analytics)
Dockerfiles
Q&A
Docker Compose
What is Docker Compose
Docker-compose.yml
Docker?
● “VM inside VM”
Docker containers are not VMs
● Easy connection to make
● Fundamentally different architectures
● Fundamentally different benefits
Some Docker Vocabularies
Docker Image
The basis of a Docker container. Represents a full application

Docker Container
The standard unit in which the application service resides and executes

Registry Service (Docker Hub or Docker Trusted Registry)


Cloud or server based storage and distribution service for your images
What is a container?

● Standardized packaging
for software and
dependencies
● Isolate apps from each
other
● Share the same OS kernel
● Works for all major Linux
distributions
Why dockerize your project?
● Best developer reason -> “it doesn’t work on my machine!”
● Reduce time for project setup in local development environment
● Make deployment to cloud platform (AWS, GCP, Azure) easy!
Dockerfile

● Instructions on how to
build a Docker image

● Looks very similar to


“native” commands

● Important to optimize
your Dockerfile
Basic Docker Commands

$ docker image pull redis:latest


$ docker image ls
$ docker container run –d –p 6379:6379 –-name redis
redis:latest
$ docker container ps
$ docker container stop redis (or <container id>)
$ docker container rm redis (or <container id>)
$ docker image rm redis:latest (or <imageid>)
$ docker build –t imrenagi/rojak-api:2.0 .
$ docker image push imrenagi/rojak-api:2.0
Docker Compose: Multi Container Applications
Docker compose is a tool for creating and managing
multi container applications
● Containers are all defined in a single file called docker-compose.yml
● Each container runs a particular component/service of your application. For
example:
○ Web frontend
○ User authentication
○ Payments gateway
○ Database
● Compose will spin up all of your containers in a single command
Docker Compose: Multi Container Applications

● Define multi container app in


● Build and run one container at a compose.yml file
time ● Single command to deploy entire app
● Manually connect container ● Handle container dependencies
together ● Works with Docker Swarm, Networking,
● Must be careful with dependencies Volumes
and start up order ● Easy to migrate the application to
Kubernetes
Docker Compose: Multi Container Applications
Docker-Compose
Demo/Hands On
https://github.com/imrenagi/tweet-livestream
Real-time twitter sentiment analytics
Requirements:
● Read live stream tweet from twitter stream API
● Determine the sentiment of a tweet (positive, negative, or neutral)
● Show the number of tweet based on its sentiment in frontend web application
via web browser

Context:
● Imagine we are working on a big company consists of several teams, in
where each small team is responsible to maintain a particular service
● Microservices??
Application Architecture (Monolith)

Twitter
stream API
Application Architecture (Microservice?)

Twitter
stream API
Machine Pub/Sub Serving Layer:
Learning Service Frontend App
Service Service

Easy to scale each


microservice!!
Dockerfile for Machine learning service
Dockerfile for Frontend service
Docker-compose.yml
docker-compose up
And let the magic begins
THANK YOU :)
@imrenagi

You might also like