Hands-On Labs Docker Containerized

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Hands-on Labs Docker Containerized

Objectives:
● Learn what is Docker Container and its principles
● Guided tour to Docker installation dan labs

Syllabus
● Introduction to Cloud Native, Docker, and Kubernetes
● Installation Docker CLI
● Setup Dockerfile and docker-compose
● Build docker Image
● Run Image in Container

Lecture Notes 1: Cloud Native

Summary:
● What is Cloud Native?
● How does a cloud-native approach benefit businesses
● What is the CNCF
● Cloud-native Architecture
● Application development
Lecture Notes 2: Containers
Summary:
● VM vs Container

● 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
● Docker
○ Docker image
○ Docker container
○ Docker engine
○ Docker registry (docker hub, google container registry, etc.)

Hands-on Labs 1 :
● Installation Docker
On Windowsa
On macOS
On Linux Ubuntu 20.04

Ip : 203.210.84.159
Port 9299
Username : nama sendiri
Password : alka2023

sudo apt update


sudo apt install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

apt-cache policy docker-ce

sudo apt install docker-ce

sudo systemctl status docker

Docker Compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname


-m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker-compose --version

● Docker basic commands

docker version Melihat versi docker

docker search: Mencari docker image di docker hub (docker


docker search nginx registry)

docker pull : Mendownload image nginx


docker pull nginx

docker images Melihat docker images

docker container create --name webserver -p Membuat docker container webserver dengan nginx
80:80 nginx

docker container start webserver Menjalankan docker container

docker container stop webserver Stop docker container

docker container ls Melihat container yg berjalan


docker ps

docker container ls -a Melihat semua container

docker rm web server(nama container) Menghapus docker container

docker rmi (nama images) Menghapus docker images

docker exec -it webserver bash Masuk ke dalam container

docker login Login akun docker registry


username :
password :
● Create Dockerfile

$ mkdir app_demo Membuat direktori App


cd app_demo

$ nano Dockerfile nano Dockerfile


Example script :

FROM node:16.14.0-alpine

WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD ["node", "app.js"]
EXPOSE 3000

● Build docker Image

$ docker build -t alkademi/demoapp:1.0 . Build docker image

$ docker images cek docker images

● Run Image in Container

$ docker run -d --name app_demo -p Menjalankan container dengan image


3000:3000 alkademi/demoapp:1.0 yg baru dibuat

● Push Images to docker hub

Login to docker hub


$ docker login
username :
Password :

$ docker tag alkademi/demoapp:1.0 Create docker tag


devradyalabs/demoapp:1.0

$ docker push Push docker images to docker hub


devradyalabs/demoapp:1.0
● Create Docker compose

$ sudo nano docker-compose.yml Create file docker-compose.yml

$ Example script :

version: '3.7'
services:
app:
container_name: app_demo
image: devradyalabs/demoapp:1.0
ports:
- 3000:3000
networks:
- app
networks:
app:

$ docker-compose up -d

$ docker ps Cek container yang berjalan

Lecture Notes 2: Kubernetes


Summary:
● What is Kubernetes?
● Why we need Kubernetes?
● Kubernetes architecture
○ Control plane node
■ API server
■ Scheduler
■ Controller manager
■ ETCD
○ Worker node
■ Kubelet
■ Kube-proxy
○ Kubernetes network model: Container Network Interface (CNI) Plugins
● Declarative vs imperative in Kubernetes
● Kubernetes basic concepts for developers
Hands-on Labs 2 :
● Installation Minikube
Linux
macOS
Windows
● Push Docker Image to Registry
Docker Hub
● Setup kube.yml
● Deploy to Kube
● Custom CPU & Memory and kLoad balancing

You might also like