Docker Community Forums

Share and learn in the Docker community.

How to create mysql service importing a dump?

I’m trying to create a local mysql service into my dev machine.

But I need to dump my actual db INTO the service, at build time.

FROM mysql:5.5.52

COPY it_www.sql /tmp

RUN /bin/bash -c "/usr/bin/mysqld_safe &" \
  && sleep 5 \
  && mysql -u root -e "CREATE DATABASE it_www" \
  && mysql -u root mydb < /tmp/it_www.sql

At build time I got

/bin/bash: /usr/bin/mysqld_safe: No such file or directory ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mys ql.sock' (2)

Please note that actually mysql:5.5.52 is based on an old ubuntu:jessie


$ docker run -it mysql:5.5.52 bash
root@32050511b53f:/# /bin/bash -c "/usr/bin/mysqld_safe &"
root@32050511b53f:/# /bin/bash: /usr/bin/mysqld_safe: No such file or directory

root@32050511b53f:/# find / -name "mysqld_safe"