Putting the M in LAMP
In Part I we built a Dockerfile to generate the LAP part of a LAMP server. Now, all we need to do is add instructions to a Dockerfile in order to install and start MySQL.
# MySQL Server.
# Version 0.1
FROM ubuntu:12.04
MAINTAINER Last Mile Synergy, LLC
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl
RUN apt-get update
RUN apt-get install -y mysql-server
RUN apt-get clean
RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
RUN /usr/sbin/mysqld & sleep 10s && echo "GRANT ALL ON *.* TO admin@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES" | mysql
EXPOSE 3306
CMD ["/usr/sbin/mysqld"]
Save the Dockerfile in its own directory and build the MySQL image with:
$ sudo docker build -rm -t MySQL .
Now we start a container from the image and then check what container ID is created:
$ sudo docker run -d MySQL
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d4d558ba4c83 MySQL:latest /usr/sbin/mysqld 4 seconds ago Up 4 seconds 3306/tcp kickass_pike
79f65558f236 apache-php:latest /usr/sbin/apache2 -D About an hour ago Up About an hour 80/tcp mad_pare
Now we have Apache, PHP, and MySQL all running within Linux (aka LAMP).
Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer