I am building a website and trying to deploy the whole stack using docker compose.
The website needs a database, an api, a middleware translation layer and a frontend that are all able to communicate with eachother.
I have understood that I might need a network. So I made one.
Problem is that all containers get random ip adresses within the ip range.
it seems aux_adresses does not do the thing I thought it did...
services:
db:
image: neo4j:community
restart: unless-stopped
volumes:
- ./conf:/conf
- ./data:/data
- ./import:/import
- ./logs:/logs
- ./plugins:/plugins
environment:
# Raise memory limits
- NEO4J_AUTH=neo4j/password
- NEO4J_dbms_memory_pagecache_size=1G
- NEO4J_dbms.memory.heap.initial_size=1G
- NEO4J_dbms_memory_heap_max__size=1G
ports:
- 7474:7474
- 7687:7687
networks:
- matrix-network
api:
build: ./api/.
restart: unless-stopped
ports:
- 8000:8000
networks:
- matrix-network
middleware:
build:
./database-middleware/.
restart: unless-stopped
ports:
- 4000:4000
networks:
- matrix-network
web:
build:
./.
restart: unless-stopped
ports:
- "80:80"
networks:
- matrix-network
networks:
matrix-network:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
ip_range: 172.28.5.0/24
gateway: 172.28.5.254
aux_addresses:
api: 172.28.1.5
db: 172.28.1.6
middleware: 172.28.1.7
web: 172.28.1.8
just use the service name instead of an ip.
so for example: http://middleware:4000
instead of the ip.
thx @tkausl
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.