- person Penulis:
-
Dimas Maryanto
PT. Tabeldata Informatika
- account_balance_wallet Donasi via:
- Saweria a/n Dimas Maryanto
- lock_open Join Premium Members:
- Udemy.com
-
Daftar Materi
-
1. Pengenalan Docker 8
-
2. Docker Registry 3
-
3. Docker Container CLI 8
-
1. Docker CLI (Command Line Interface)
2. Management Docker Container
3. Management Docker Images
4. Run a command in a running container
5. Expose services to outside using ports
6. Copying files/content between container and filesystem
7. Logging, Inspect, & Resource Usage Statistics Containers
8. Run a Container using Environtment File
-
4. Docker Networks 7
-
5. Docker Volumes 5
-
6. Dockerfile 15
-
1. Build Docker Image Overview
2. Usage docker build
3. FROM Instruction
4. Environtment Replacement
5. Copying Resources
6. Excluding files/directories
7. Label Instruction
8. Execution Instruction
9. CMD vs ENTRYPOINT?
10. Exposing Ports
11. User, Volumes and Working Directory
12. Health Check Instruction
13. Multiple Stage Builds
14. Best practices for writing Dockerfiles
15. Best practices for scanning images
-
7. Study Kasus: Build docker image 14
-
1. Build specific docker image by programming languages
2. Build Docker Image for Java Webapp
3. Build Java Web using maven-docker-plugin
4. Build docker image for spring-boot
5. Springboot - using Environtment
6. Springboot - where data such as files/images we stored?
7. Springboot - Using Database
8. Build docker image for Angular Project
9. Angular - Access Rest API
10. Angular - Proxy to backend
11. Build docker image for PHP
12. Build Docker image for Laravel Framework
13. Laravel - Using Frontend & Rest API
14. Laravel - Using Database
-
8. Docker Compose 19
-
1. Overview of Docker Compose
2. Get started with Docker Compose
3. Overview of docker-compose CLI
4. Compose file specification and syntax
5. Environment variables in Compose
6. Volume in Compose
7. Share data between Containers in Compose
8. Using sshfs for share data in Compose
9. Using NFS for share data in Compose
10. Networking Overview in Compose file
11. Network links in Compose file
12. Specify custom networks in Compose file
13. Dependency between services in Compose file
14. Build docker image using Compose file
15. Using profiles with Compose file
16. Multiple Compose files to Add & Override attribute
17. Example use case of multiple compose files
18. Scale services using compose command
19. Use Compose in production
-
9. Study Kasus: Docker Compose 7
-
10. Docker Context 8
-
11. Study Kasus: Docker for CI 8
-
1. Overview of Study Cases using docker for CI
2. Setup environment for CI using Gitlab & Nexus OSS
3. The `.gitlab-ci.yml` file
4. Pipeline: PHP deployment using Gitlab CI
5. Pipeline: Java Web deployment using Gitlab CI
6. Pipeline: spring-boot deploy with Gitlab CI
7. Pipeline: Angular deploy with Gitlab CI
8. Pipeline: Laravel deploy with Gitlab CI
-
12. Docker Machine 7
-
13. Study Kasus: Ansible for Docker 4
-
14. Docker Swarm
- Materi: belum tersedia...
-
15. Study Kasus: Docker Swarm
- Materi: belum tersedia...
-
16. Docker on Cloud using GCP
- Materi: belum tersedia...
- Lastest Posts
- 09 Apr 23 Working with Deployment object
- 26 Feb 23 Study cases: Microservice apps (...
- 05 Feb 23 Welcome to the Nutanix HCF (Hybr...
- 04 Feb 23 Silabus SRE - Nutanix AHV: Pemul...
- 17 Jan 23 What is Workload Resources?
- 17 Jan 23 Overview Kubernetes Workloads re...
- 15 Jan 23 Getting started with Transaction...
- 14 Jan 23 Overview of Concurrency Control
- 14 Jan 23 Time your practice (part 3)
- 08 Jan 23 Cleanup Data from Table
Health Check Instruction
Hai semuanya, di materi kali ini kita akan membahas tentang Health Check pada Dockerfile.
The HEALTHCHECK
instruction tells Docker how to test a container to check that it is still working. This can detect cases such as a web server that is stuck in an infinite loop and unable to handle new connections, even though the server process is still running.
When a container has a healthcheck specified, it has a health status in addition to its normal status. This status is initially starting
. Whenever a health check passes, it becomes healthy (whatever state it was previously in). After a certain number of consecutive failures, it becomes unhealthy
.
The HEALTHCHECK instruction has two forms:
HEALTHCHECK [OPTIONS] CMD command
(check container health by running a command inside the container)HEALTHCHECK NONE
(disable any healthcheck inherited from the base image)
The options that can appear before CMD are:
--interval=DURATION
(default: 30s)--timeout=DURATION
(default: 30s)--start-period=DURATION
(default: 0s)--retries=N
(default: 3)
There can only be one HEALTHCHECK
instruction in a Dockerfile. If you list more than one then only the last HEALTHCHECK
will take effect.
The command after the CMD
keyword can be either a shell command (e.g. HEALTHCHECK CMD /bin/check-running)
or an exec array (as with other Dockerfile commands; see e.g. ENTRYPOINT
for details).
The command’s exit status indicates the health status of the container. The possible values are:
0: success
- the container is healthy and ready for use1: unhealthy
- the container is not working correctly2: reserved
- do not use this exit code
For example, to check every five minutes or so that a web-server is able to serve the site’s main page within three seconds:
Contoh penggunaannya seperti berikut:
Jika di jalankan maka hasilnya seperti berikut:
➜ 07-dockerfile docker build -t dimmaryanto93/centos:1.6 .
[+] Building 0.1s (9/9) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 592B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 35B 0.0s
=> [internal] load metadata for docker.io/library/centos:7 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 32B 0.0s
=> [1/4] FROM docker.io/library/centos:7 0.0s
=> CACHED [2/4] RUN yum install epel-release -y && yum install nginx -y 0.0s
=> CACHED [3/4] WORKDIR /usr/share/nginx/html 0.0s
=> CACHED [4/4] COPY index.html . 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:64b1d99eeb283c88d0352dd8bb9544edcc4b52551dc8848226341caa03f1204e 0.0s
=> => naming to docker.io/dimmaryanto93/centos:1.6
➜ 07-dockerfile docker run -d --name webapp dimmaryanto93/centos:1.6
9f60172ba90b620dc2d5d424b0469f4a4fb7306632ea9f3e80af8d886aed6a85
➜ 07-dockerfile watch docker container ls
Every 2.0s: docker container ls MSI-z390-pro: Tue Jun 22 20:36:24 2021
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
e7eb90183981 dimmaryanto93/centos:1.6 "nginx -g 'daemon of…" 3 seconds ago Up 3 seconds (health: starting)
webapp
## wait 10 detik hasilnya seperti berikut
Every 2.0s: docker container ls MSI-z390-pro: Tue Jun 22 20:37:09 2021
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
e7eb90183981 dimmaryanto93/centos:1.6 "nginx -g 'daemon of…" 29 seconds ago Up 28 seconds (healthy)
webapp
## sekarang coba stop service nginxnya
➜ 07-dockerfile docker exec -it webapp nginx -s stop
## containerpun ikut mati
Every 2.0s: docker container ls MSI-z390-pro: Tue Jun 22 20:39:27 2021
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
➜ 07-dockerfile docker run -it --name webapp2 dimmaryanto93/centos:1.6 bash
[root@abaef666dfb9 html]#
Every 2.0s: docker container ls MSI-z390-pro: Tue Jun 22 20:40:26 2021
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
abaef666dfb9 dimmaryanto93/centos:1.6 "bash" 18 seconds ago Up 17 seconds (unhealthy) webapp2
## Jalankan service nginx
[root@abaef666dfb9 html]# nginx
## statunya sekarang jadi healty
Every 2.0s: docker container ls MSI-z390-pro: Tue Jun 22 20:41:27 2021
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
abaef666dfb9 dimmaryanto93/centos:1.6 "bash" About a minute ago Up About a minute (healthy) webapp2
Jadi kesimpulanya, dengan healthcheck Instruction ini kita bisa memastikan bahwa service yang kita buat sudah berjalan dengan sempura.
Cleanup
Seperti biasa, setelah kita coba sekarang saatnya bersih-bersih. berikut perintahnya:
For Bash script:
For Powershell script:
Yuk simak juga videonya,
Dan jika temen-temen belajar hal baru kali ini jangan lupa buat Like, Subcribe, dan Share ke temen kalian. Terimakasih!!!