Answer the question
In order to leave comments, you need to log in
Docker, MySql is running?
Colleagues, hello!
How to determine if mysql is running in a container?
After all the containers are running, the database is not yet available, (it starts, creates tables, databases if there are none)
The first run is quite long.
I need to somehow determine that the database is ready.
The code below is not suitable, as it determines the fact that the container is running, but I do not need it.
I need something similar to this.
echo "Waiting for DB to start up..."
while(docker inspect rosinter.db --format '{{.State.Running}}' -eq 'false'){
Start-sleep 5
}
Answer the question
In order to leave comments, you need to log in
while ! mysqladmin ping -h"$DB_HOST" --silent; do
sleep 1
done
version: "2.1"
services:
api:
build: .
container_name: api
ports:
- "8080:8080"
depends_on:
db:
condition: service_healthy
db:
container_name: db
image: mysql
ports:
- "3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_USER: "user"
MYSQL_PASSWORD: "password"
MYSQL_DATABASE: "database"
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question