Ping one service from another in CI

variables:
  MYSQL_RANDOM_ROOT_PASSWORD: "yes"
  ZOOKEEPER_CLIENT_PORT: "2121"
  KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2121"
  KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://kafka:9092'
  
services:
  - name: mysql:latest
    alias: mysql-1
  - name: confluentinc/cp-zookeeper
    alias: zookeeper
  - name: confluentinc/cp-kafka
    alias: kafka
    entrypoint: ["ping","-c1", "mysql-1"]

ping:
  image: python:2
  script:
  - ping -c 1 zookeeper
  - ping -c 1 kafka

When kafka is up it can’t reach mysql container by alias (or by name ‘mysql’)

1 Like