mysql.dockerfile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. FROM ubuntu:16.04
  2. RUN apt-get update
  3. RUN apt-get install -qqy locales
  4. RUN locale-gen en_US.UTF-8
  5. ENV LANG en_US.UTF-8
  6. ENV LANGUAGE en_US:en
  7. ENV LC_ALL en_US.UTF-8
  8. ADD create.sql create.sql
  9. ADD my.cnf my.cnf
  10. ADD mysql.list mysql.list
  11. RUN cp mysql.list /etc/apt/sources.list.d/
  12. RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C718D3B5072E1F5
  13. RUN apt-get update
  14. RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/data-dir select 'Y'\""]
  15. RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/root-pass password secret\""]
  16. RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/re-root-pass password secret\""]
  17. RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server
  18. RUN mv /etc/mysql/my.cnf /etc/mysql/my.cnf.orig
  19. RUN cp my.cnf /etc/mysql/my.cnf
  20. RUN rm -rf /ssd/mysql
  21. RUN rm -rf /ssd/log/mysql
  22. RUN cp -R -p /var/lib/mysql /ssd/
  23. RUN cp -R -p /var/log/mysql /ssd/log
  24. # It may seem weird that we call `service mysql start` several times, but the RUN
  25. # directive is a 1-time operation for building this image. Subsequent RUN calls
  26. # do not see running processes from prior RUN calls; therefor, each command here
  27. # that relies on the mysql server running will explicitly start the server and
  28. # perform the work required.
  29. RUN service mysql start && \
  30. mysqladmin -uroot -psecret flush-hosts && \
  31. mysql -uroot -psecret < create.sql
  32. EXPOSE 3306
  33. CMD ["mysqld"]