Skip to content

Instantly share code, notes, and snippets.

@r2brain
Forked from benschw/Dockerfile
Last active August 29, 2015 14:07
Show Gist options
  • Save r2brain/9e09fa0a94b7185aaf73 to your computer and use it in GitHub Desktop.
Save r2brain/9e09fa0a94b7185aaf73 to your computer and use it in GitHub Desktop.
#!/bin/sh
docker build -t mysql .
FROM eboraas/debian:stable
RUN apt-get update
RUN apt-get upgrade -y
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 3306
CMD ["/bin/bash", "/opt/startup.sh"]
#!/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
#!/bin/sh
docker run -d -p 3306:3306 -v /data/mysql:/var/lib/mysql mysql
#/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
@r2brain
Copy link
Author

r2brain commented Oct 17, 2014

Build a mysql container from debian stable with docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment