Skip to content

Waiting for MySQL to come up before talking to it #547

@bentcoder

Description

@bentcoder

Hi,

This line prevents my custom /docker-entrypoint-initdb.d/init.sh from being run after container built. I need a way to run this script without removing the content of the data dir. What's the workaround for this issue? I don't want to send any request from other containers to MySQL container if it is not ready.

Thanks

Dockerfile

FROM mysql:5.7.24

COPY init.sh /docker-entrypoint-initdb.d/init.sh
RUN chmod +x /docker-entrypoint-initdb.d/init.sh

/docker-entrypoint-initdb.d/init.sh

#!/bin/sh
set -e

echo "Check DB!"
while ! MYSQL_PWD=custom_password mysqladmin -u custom_user ping -h localhost; do
    echo "Wait ..."
    sleep 1
done
echo "DB ready!"

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions