When I execute the xdcomp_my_sql_client command it pings the ip but then when it tries to reach the mysql server it fails. If I do the exact same command once the container is running it works. It seems that the mysql server is not running at the moment the command is executed. But I have used the "depends_on" command, so what I'm doing wrong?
Thank you.
version: '2'
services:
xdcomp_my_sql_server:
image: mysql/mysql-server:latest
environment:
MYSQL_ROOT_PASSWORD: diego
MYSQL_USER: otro
MYSQL_PASSWORD: otro
MYSQL_ROOT_HOST: 172.28.0.101
networks:
SQLNetwork:
ipv4_address: 172.28.0.102
xdcomp_my_sql_client:
build: .
command: sh -c 'ping -c 5 172.28.0.102 && mysql -h 172.28.0.102 -u root -pdiego sys < /lafayette/forensic.sql && tail -f /etc/hostname'
ports:
- 83:80
networks:
SQLNetwork:
ipv4_address: 172.28.0.101
depends_on:
- xdcomp_my_sql_server
networks:
SQLNetwork:
driver: "bridge"
ipam:
config:
- subnet: 172.28.0.0/24
gateway: 172.28.0.201
Client Dockerfile
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y mysql-client
RUN apt-get install -y git
RUN git clone https://github.com/linkedin/lafayette
RUN apt-get update
RUN apt-get install -y python-dnspython
RUN apt-get install -y python-pip
RUN pip install Flask
RUN pip install python-dateutil
RUN apt-get install -y python-mysqldb
RUN pip install requests
RUN pip install multiprocessing
RUN pip install multiprocess
RUN apt-get install -y vim
RUN apt-get -y install iputils-ping