Posted in

Day 3 – Training DevOps

Introduction

Untuk hari ketiga saya tidak berada di IDN karena saya berada di kantor untuk mengambil beberapa dokumen. Untuk hari ketiga saya berangkat dari kantor habis subuh, sampai IDN sekitar jam 6.30.

Discussion

Pada hari ketiga kita melanjutkan pembahasan mengenai docker.

Docker Registry

Pada pembahasan kali ini kita akan menggunakan registry dari docker hub yang bersifat opensource. Beberapa hal yang harus diketahui yaitu jika menggunakan docker hub ada limitasi untuk private repository yaitu 1 private repository. Rekomendasi untuk private repository yaitu menggunakan Harbor.

Berikut command untuk menggunakan docker hub

docker loginlogin docker
docker tag {NAMEIMAGE}:{TAG} {NAMEDOCKERHUB}/{PROJECT}:{TAG}rename image and tag names for same with the account and project of dockerhub repo
docker push {NAMEDOCKERHUB}/{PROJECT}:{TAG}push image, must be same from account and project name from dockerhub
docker pull {NAMEDOCKERHUB}/{PROJECT}:{TAG}for pull image from dockerhub

Contoh penerapan

ocker tag simple-apps:latest zainunkamal/simple-apps:v1.0     
docker push zainunkamal/simple-aaps:v1.0
docker pull zainunkamal/simple-aaps:v1.0

Docker Volume

Docker volume berfungsi untuk membuat storage docker. Jika kita tidak menggunakan docker volume, maka ketika kita sudah melakukan update data pada container kemudian kita restart docker tersebut, maka data tidak akan tersimpan.

Berikut beberapa command docker volume

docker volume lslist volume
docker volume create {NAMEVOLUME}create volume
docker volume inspect {NAMEVOLUME}Inspect the volume

Contoh penerapan

docker volume create vol-a
docker run -dit --name ct-vol-a -v vol-a:/data ubuntu:24.04
docker exec -it ct-vol-a touch /data/test.txt
ls /var/lib/docker/volumes/vol-a/_data/

Docker Network

Secara default, docker sudah ada network. Docker network beguna jika kita ingin memisahkan segmentasi antar container agar tidak bisa terhubung satu sama lain.

Berikut beberapa command docker network

docker network lsfor check list of the network
docker network create –subnet {IPSUBNET} {NAMENETWORK}create new network with custom subnet
docker network inspect {NAMENETWORK}inspect the network
docker network connect {NAMECT} {NAMENETWORK}connecting from ct to specific network (this will create new ip address)

Contoh penerapan

docker network create --subnet 10.10.10.0/24 net-a
docker network inspect net-a
docker network connect ct-a net-a 

Docker Compose

Docker compose berfungsi untuk menjalankan beberapa container docker dari satu script. Bisa menjalankan build atau pull images.

Beberapa command docker compose

docker compose buildwill building docker if there has the build before we start
docker compose up -dwill start docker from file docker-compose.yml (and will detach)
docker compose pswill check docker status within docker-compose.yaml
docker compose downwill terminate docker within docker-compose.yml

Portainer (Docker Dashboard)

Sekarang kita melakukan instalasi portainer yang berfungsi untuk memudahkan kita untuk manage docker dengan dashboard, untuk instalasi bisa dilihat pada dokumentasi resmi https://docs.portainer.io/start/install-ce/server/docker/linux

Docker Logging

Kita belajar mengenai logging pada docker. Log sebagai salah satu metode untuk troubleshooting ketika ada error pada container docker.

Berikut beberapa command docker logging

docker logs {NAMECT}check logs from ct
docker compose logs {NAMESVCAPP}check logs if using docker compose and use service app
docker system events / docker eventscheck logs from docker itself like creating ct, volumes, nets, and etc (using –since 1h for check last 1 hour)

Untuk training hari ke-3 terdapat masalah pada koneksi ke internet seperti ke github, dll. Jadi untuk materi selanjutnya kita akan dilakukan pada hari berikutnya

Leave a Reply

Your email address will not be published. Required fields are marked *