Created
July 11, 2014 12:13
-
-
Save swvitaliy/dd1de98e24a4a22accac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
docker build -t mysql . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQL | |
# | |
# Version 1 | |
# Use the Ubuntu base image from dotCloud | |
FROM ubuntu:12.04 | |
MAINTAINER Brian Shaw [email protected] | |
RUN dpkg-divert --local --rename --add /sbin/initctl | |
RUN ln -s /bin/true /sbin/initctl | |
# Update apt repos | |
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list | |
RUN apt-get update | |
# Install MySQL | |
RUN apt-get -y install mysql-client mysql-server | |
RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf | |
ADD ./startup.sh /opt/startup.sh | |
# Expose MySQL port | |
EXPOSE 3306 | |
CMD ["/bin/bash", "/opt/startup.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TAG="mysql" | |
CONTAINER_ID=$(docker ps | grep $TAG | awk '{print $1}') | |
IP=$(docker inspect $CONTAINER_ID | python -c 'import json,sys;obj=json.load(sys.stdin);print obj[0]["NetworkSettings"]["IPAddress"]') | |
mysql -u admin -p -h $IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
docker run -d -p 3306:3306 -v /data/mysql:/var/lib/mysql mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
if [ ! -f /var/lib/mysql/ibdata1 ]; then | |
mysql_install_db | |
/usr/bin/mysqld_safe & | |
sleep 10s | |
echo "GRANT ALL ON *.* TO admin@'%' IDENTIFIED BY 'changeme' WITH GRANT OPTION; FLUSH PRIVILEGES" | mysql | |
killall mysqld | |
sleep 10s | |
fi | |
/usr/bin/mysqld_safe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment