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 :
Hapus network yang dibuat dari docker compose, bisa melalui portainer biar lebih user friendly. Tapi cara ini krusial apabila production, jangan sampai salah hapus
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 :
- Stuckoverflow : How to join the default bridge network with docker-compose v2
- Run the containers in default bridge network with docker-compose.yml
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