- 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
Example use case of multiple compose files
Hai semuanya, di materi kali ini kita akan membahas tentang contoh kasusnya dalam penggunaan multiple compose file. Diantaranya:
- Changing a Compose app for different environments
- Running administrative tasks against a Compose app
Ok langsung aja kita ke pembahasan yang pertama
Different environments
A common use case for multiple files is changing a development Compose app for a production-like environment (which may be production, staging or CI). To support these differences, you can split your Compose configuration into a few different files:
Start with a base file that defines the canonical configuration for the services. docker-compose.yaml
In this example the development configuration exposes some ports to the host, mounts our code as a volume, and builds the web image. docker-compose.override.yaml
When you run docker-compose up
it reads the overrides automatically.
Now, it would be nice to use this Compose app in a production environment. So, create another override file (which might be stored in a different git repo or managed by a different team).
To deploy with this production Compose file you can run
This deploys all three services using the configuration in docker-compose.yml
and docker-compose.prod.yml
(but not the dev configuration in docker-compose.override.yml
).
➜ docker docker-compose --project-directory .\09-docker-compose\multiple-compose\diff-envs\ config
networks:
backend: {}
frontend: {}
services:
backend:
depends_on:
db:
condition: service_started
image: php:8.0-apache
networks:
backend: {}
frontend: {}
ports:
- published: 8080
target: 80
db:
environment:
POSTGRES_DB: example_db
POSTGRES_PASSWORD: secretPassword
POSTGRES_USER: example_user
image: postgres:12.6
networks:
backend: {}
ports:
- published: 5432
target: 5432
volumes:
- source: pg_data
target: /var/lib/postgresql/data
type: volume
webapp:
image: nginx:latest
networks:
frontend: {}
ports:
- published: 80
target: 80
volumes:
- C:\Users\dimasm93\Workspaces\youtube\docker\09-docker-compose\multiple-compose\diff-envs\html:/usr/share/nginx/html:rw
version: '3.9'
volumes:
pg_data: {}
➜ docker docker-compose -f .\09-docker-compose\multiple-compose\diff-envs\docker-compose.yaml `
>> -f .\09-docker-compose\multiple-compose\diff-envs\docker-compose.prod.yaml config
networks:
backend: {}
frontend: {}
services:
backend:
build:
args:
PHP_VERSION: 8.0-apache
context: C:\Users\dimasm93\Workspaces\youtube\docker\09-docker-compose\multiple-compose\diff-envs
dockerfile: Dockerfile-php
depends_on:
db:
condition: service_started
image: php:8.0-apache
networks:
backend: {}
frontend: {}
db:
environment:
POSTGRES_DB: prod_db
POSTGRES_PASSWORD_FILE: /run/secrets/postgres-passwd
POSTGRES_USER: user_prod
image: postgres:12.6
networks:
backend: {}
volumes:
- source: pg_data
target: /var/lib/postgresql/data
type: volume
webapp:
build:
args:
NGINX_VERSION: mainline
context: C:\Users\dimasm93\Workspaces\youtube\docker\09-docker-compose\multiple-compose\diff-envs
dockerfile: Dockerfile
image: nginx:latest
networks:
frontend: {}
ports:
- published: 80
target: 80
version: '3.9'
volumes:
pg_data: {}
Administrative tasks
Another common use case is running adhoc or administrative tasks against one or more services in a Compose app. This example demonstrates running a database backup. docker-compose.yaml
In a docker-compose.admin.yml
add a new service to run the database migrate, backup or exports.
To start a normal environment run docker-compose up -d
. To run a database backup, include the docker-compose.admin.yml
as well.
Jika dijalankan maka hasilnya seperti berikut:
➜ docker docker-compose -f .\09-docker-compose\multiple-compose\admin-task\docker-compose.yaml `
>> -f .\09-docker-compose\multiple-compose\admin-task\docker-compose.admin-task.yaml config
networks:
backend: {}
services:
backend:
depends_on:
db:
condition: service_started
image: php:8.0-apache
networks:
backend: {}
ports:
- published: 8080
target: 80
db:
environment:
POSTGRES_DB: example_db
POSTGRES_PASSWORD: secretPassword
POSTGRES_USER: example_user
image: postgres:12.6
networks:
backend: {}
ports:
- published: 5432
target: 5432
volumes:
- source: pg_data
target: /var/lib/postgresql/data
type: volume
migrate:
command:
- -user=
- -password=
- -url=jdbc:postgresql://postgres:5432/
- info
depends_on:
db:
condition: service_started
environment:
FLYWAY_EDITION: null
image: flyway/flyway:latest-alpine
networks:
backend: {}
version: '3.9'
volumes:
pg_data: {}
Yuk simak juga videonya,
Dan jika temen-temen belajar hal baru kali ini jangan lupa buat Like, Subcribe, dan Share ke temen kalian. Terimakasih!!!
-
Referensi
https://docs.docker.com/compose/extends/