- 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
Dependency between services in Compose file
Hai semuanya, di materi kali ini kita akan membahas tentang Service Dependencies dalam Compose file.
Service Dependency adalah the most-common dalam pengembangan aplikasi, component paling basic atau minimal biasanya kita memerlukan database atau external service. Sebagai contoh misalnya klo kita menjalankan aplikasi tapi tanpa database maka akan terjadi failure.
Pada Compose file, ada depends_on
. Express dependency between services. Service dependencies cause the following behaviors:
docker-compose up
starts services in dependency order. In the following example,db
andmigrate-tool
are started beforeweb
.docker-compose up SERVICE
automatically includesSERVICE’s
dependencies. In the example below,docker-compose up web
also creates and startsdb
andmigrate-tool
.docker-compose stop
stops services in dependency order. In the following example,web
is stopped beforedb
.
Dan berikut adalah file .env
:
Jika di jalankan maka hasilnya seperti berikut:
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml config
services:
migrate-tools:
command:
- -user=bisnis_app
- -password=secretPassword
- -url=jdbc:postgresql://postgres:5432/bisnis_app
- info
depends_on:
postgres:
condition: service_started
environment:
FLYWAY_EDITION: community
image: flyway/flyway:latest-alpine
postgres:
environment:
POSTGRES_DB: bisnis_app
POSTGRES_PASSWORD: secretPassword
POSTGRES_USER: bisnis_app
image: postgres:12.6
ports:
- published: 5432
target: 5432
volumes:
- pg_data:/var/lib/postgresql/data:rw
web:
depends_on:
migrate-tools:
condition: service_started
postgres:
condition: service_started
image: nginx
ports:
- published: 80
target: 80
volumes:
- C:\Users\dimasm93\Workspaces\youtube\docker\09-docker-compose\dependency\html:/usr/share/nginx/html:rw
version: '3.9'
volumes:
pg_data: {}
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency up -d
Creating network "dependency_default" with the default driver
Creating volume "dependency_pg_data" with default driver
Creating dependency_postgres_1 ... done
Creating dependency_migrate-tools_1 ... done
Creating dependency_web_1 ... done
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------------
dependency_migrate-tools_1 flyway -user=bisnis_app -p ... Exit 0
dependency_postgres_1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp,:::5432->5432/tcp
dependency_web_1 /docker-entrypoint.sh ngin ... Up 0.0.0.0:80->80/tcp,:::80->80/tcp
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency logs migrate-tools
Attaching to dependency_migrate-tools_1
migrate-tools_1 | Flyway Community Edition 7.14.0 by Redgate
migrate-tools_1 | Database: jdbc:postgresql://postgres:5432/bisnis_app (PostgreSQL 12.6)
migrate-tools_1 | Schema version: << Empty Schema >>
migrate-tools_1 |
migrate-tools_1 | +----------+---------+-------------+------+--------------+-------+
migrate-tools_1 | | Category | Version | Description | Type | Installed On | State |
migrate-tools_1 | +----------+---------+-------------+------+--------------+-------+
migrate-tools_1 | | No migrations found |
migrate-tools_1 | +----------+---------+-------------+------+--------------+-------+
migrate-tools_1 |
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency down
Stopping dependency_web_1 ... done
Stopping dependency_postgres_1 ... done
Removing dependency_web_1 ... done
Removing dependency_migrate-tools_1 ... done
Removing dependency_postgres_1 ... done
Removing network dependency_default
# testing start from service name: migrate-tools
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency up -d migrate-tools
Creating network "dependency_default" with the default driver
Creating dependency_postgres_1 ... done
Creating dependency_migrate-tools_1 ... done
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency down
Stopping dependency_postgres_1 ... done
Removing dependency_migrate-tools_1 ... done
Removing dependency_postgres_1 ... done
Removing network dependency_default
# testing start from service name: web
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency up -d web
Creating network "dependency_default" with the default driver
Creating dependency_postgres_1 ... done
Creating dependency_migrate-tools_1 ... done
Creating dependency_web_1 ... done
➜ docker docker-compose -f .\09-docker-compose\dependency\docker-compose.yaml -p dependency down --volumes
Stopping dependency_web_1 ... done
Stopping dependency_postgres_1 ... done
Removing dependency_web_1 ... done
Removing dependency_migrate-tools_1 ... done
Removing dependency_postgres_1 ... done
Removing network dependency_default
Removing volume dependency_pg_data
There are several things to be aware of when using depends_on
:
depends_on
does not wait for db andmigrate-tools
to be “ready” before startingweb
- only until they have been started. If you need to wait for a service to be ready, see Controlling startup order for more on this problem and strategies for solving it.- The
depends_on
option is ignored when deploying a stack in swarm mode with a version 3 Compose file.
Yuk simak juga videonya,
Dan jika temen-temen belajar hal baru kali ini jangan lupa buat Like, Subcribe, dan Share ke temen kalian. Terimakasih!!!