Build own mysql dockerBuild own MySQL Docker container

Hi All,

Im new in Docker so my knowledges is less. I did the Docker tutorial and understand the concept.
But when you are new, you always have a lot of questions. So here my first one :slight_smile:

I like to build a Docker container with a old MySQL database. Just for learning purpose. Is it smart to pull a Debian image from the repo and install MySQL into it? Or build MySQL into it and then export it as a MySQL Image? How can I make sure that my databases are saved when mine container stopped?

Is there a tutorial what I can follow about this? Or how do I start?

Thanks!

Can somebody response on my message? :confused:

Try below, import is not working though.

FROM mysql:5.7

# ROOT PASSWORD
ENV MYSQL_ROOT_PASSWORD=mypassword

#ENV MYSQL_DATABASE=sampledb
ENV MYSQL_USER=sample-username
ENV MYSQL_PASSWORD=sapassword


ENV MYSQL_DATA_DIR=/var/lib/mysql \
    MYSQL_RUN_DIR=/run/mysqld \
    MYSQL_LOG_DIR=/var/log/mysql

ADD ["db_dump.sql", "/tmp/dump.sql"]

RUN /etc/init.d/mysql start && \
         mysql -u root -p$MYSQL_ROOT_PASSWORD  -e "GRANT ALL PRIVILEGES ON *.* TO 'cumulus'@'%' IDENTIFIED BY 'password';FLUSH PRIVILEGES;" && \
        mysql -u root -p${MYSQL_ROOT_PASSWORD}  < /tmp/dump.sql

#PORT
EXPOSE 3306