Skip to main content

Semuanya tentang docker-compose

Error network default driver

Jika menemukan error seperti berikut :

danger

Creating network "backend-enterprise-integration_default" with the default driver could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

How to Solve

Maka cara mengakalinya adalah seperti berikut :

  1. Hapus network yang dibuat dari docker compose, bisa melalui portainer biar lebih user friendly. Tapi cara ini krusial apabila production, jangan sampai salah hapus

  2. Tambahkan network_mode di docker compose

version: '3'
services:
namaservice:
hostname: hostname
domainname: hostname.kg
build:
context: .
dockerfile: .cicd/Dockerfile
restart: unless-stopped
network_mode: bridge
ports:
- 15111:3000

Sumber :

Attach Volume Read-Write

version: '3'
services:
namaservice:
hostname: hostname
domainname: hostname.kg
build:
context: .
dockerfile: .cicd/Dockerfile
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
#add volume yang mau di attach
- type: bind
source: /home/user/logs
target: /var/www/html/application/logs

network_mode: bridge
ports:
- 15111:3000

Attach Volume Read-Only

version: '3'
services:
namaservice:
hostname: hostname
domainname: hostname.kg
build:
context: .
dockerfile: .cicd/Dockerfile
restart: unless-stopped
# volume read only
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/user/logs:/var/www/html/application/logs:ro
network_mode: bridge
ports:
- 15111:3000

Set /etc/hosts di container

version: '3'
services:
namaservice:
hostname: hostname
domainname: hostname.kg
build:
context: .
dockerfile: .cicd/Dockerfile
restart: unless-stopped
# masukkan nama hostname dan ip
extra_hosts:
- "abc.example.co.id:10.11.12.1"
- "xyz.example.co.id:10.11.12.1"
network_mode: bridge
ports:
- 15111:3000