wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.16-1.el7.x86_64.rpm
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.16-1.el7.x86_64.rpm
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.16-1.el7.x86_64.rpm
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-server-5.7.16-1.el7.x86_64.rpmmysqlyum install -y perl
yum install -y numactl-libs
yum install -y net-tools
rpm -i mysql-community-common-5.7.16-1.el6.x86_64.rpm
rpm -i mysql-community-libs-5.7.16-1.el6.x86_64.rpm
rpm -i mysql-community-client-5.7.16-1.el6.x86_64.rpm
rpm -i mysql-community-server-5.7.16-1.el7.x86_64.rpmlinuxgroupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /mnt/docker/mysql
rm -rf /mnt/docker/mysql/datadir/*sqlmysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/mnt/docker/mysql/datadir/docker
systemctl enable mysqld.servicecentos
exitbash
docker commit -m="mysql5.7.16 centos7 systemd啓動" 7ea468e9b950 loowj/centosmd/mysql5.6.16:0.0.1ide
docker -d 後臺運行cmd /usr/sbin/init 運行centos7
docker run -it -d --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup -v ~/loowj/docker.mnt/mysql:/mnt/docker/mysql -p 3306:3306 e0c2096791c2 /usr/sbin/initorm
進入容器cdn
nsenter --mount --uts --ipc --net --pid --target $(docker inspect --format "{{.State.Pid}}" "2a94313424f3fa")
新建一個能夠遠程的Mysql用戶
create user loowj IDENTIFIED by '123456';
grant ALL PRIVILEGES ON *.* to loowj@"%" identified by "123456" WITH GRANT OPTION;
FLUSH PRIVILEGES;
簡單啓動centosmd
docker run -it -d --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup -v ~/loowj/docker.mnt:/mnt/docker 10e35aa8b9cc
docker centos 源
mysql 運行
docker pull docker.io/centos/systemd
docker run -it --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup ~/loowj/docker.mnt/mysql:/mnt/docker/mysql -p 3306:3306 docker.io/centos/systemd /bin/bash注:loowj/centos7-mysql:0.0.2 能夠是官方純淨版
docker centos7安裝mysql
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
mkdir /usr/local/mysql
mv mysql-5.7.16-linux-glibc2.5-x86_64/* /usr/local/mysql/rm -rf mysql-5.7.16-linux-glibc2.5-x86_64*
groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /mnt/docker/mysqlyum install -y libaio
rm -rf /mnt/docker/mysql/datadir/*/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/mnt/docker/mysql/datadir/
exit 退出鏡像
dockerfile
鏡像尺寸調優:
http://www.broadview.com.cn/article/12
yum clean all