I have two different pre-existing networks created by two separated docker-compose operations. The first one is Kafka and the second one is MySQL DB. The third container is a Kafka consumer, which has to have access to the DB and Kafka topic. So I expect to connect them in another docker-compose something like this so I could use services like "db" or "broker" defined somewhere external:
version: '2'
services:
web:
build: .
environment:
KAFKA_BROKER: broker:29092
DB_MYSQL_USER: ${DB_MYSQL_REMOTE_USER}
DB_MYSQL_PASS: ${DB_MYSQL_PASS}
DB_MYSQL_ADDRESS: db:3306
KAFKA_TOPIC_NAME: ${KAFKA_TOPIC_NAME}
KAFKA_GROUP_NAME: ${KAFKA_GROUP_NAME}
networks:
db_container_default:
external: true
kafka_client_default:
external: true
Eventually, the container doesn't recognize these networks at all.
The only way to properly connect to ONLY ONE network is here.
So I ended up with settings like this, which is utter lame(connect to the exposed port of the DB by host-ip):
version: '2'
services:
web:
build: .
environment:
KAFKA_BROKER: broker:29092
DB_MYSQL_USER: ${DB_MYSQL_REMOTE_USER}
DB_MYSQL_PASS: ${DB_MYSQL_PASS}
DB_MYSQL_ADDRESS: 192.168.1.103:3307
KAFKA_TOPIC_NAME: ${KAFKA_TOPIC_NAME}
KAFKA_GROUP_NAME: ${KAFKA_GROUP_NAME}
networks:
default:
external:
name: kafka_client_default
How should I properly configure my third docker-compose?