LoginSignup
0
0

More than 5 years have passed since last update.

DockerでDBが起動中かを確認する。

Posted at

wait.sh を作成

mysqladmin コマンドを使うために、mysql-client を使っています。

wait.sh
until mysqladmin ping -h db -P 3306 --silent;
do
  echo "Waiting for database connection..."
  sleep 1
done

command: bash -c './wait.sh' で実行する

docker-compose.yml
version: "3"

services:
  db:
    image: mysql:5.7
    env_file: ./src/config/.env
    ports:
      - 3306:3306

  web:
    build: .
    command: bash -c './wait.sh'
    ports:
      - 8080:8080
    depends_on:
      - db

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0