- 官方鏡像
- 安裝
docker pull docker.io/mysql - 啟動(dòng)容器
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1qazxsw2 -d mysql:latest - 命令行輸入
mysql
報(bào)錯(cuò):ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) - 進(jìn)入mysql容器
docker exec -it mysql bash
把文件復(fù)制到容器殖蚕,在容器登錄(指定utf8要不中文亂碼)mysql -u root -p --default-character-set=utf8
登錄并執(zhí)行source abc.sql
docker run -p 3306:3306 --name mysql -v $PWD/conf/my.cnf:/etc/mysql/my.cnf -v $PWD/logs:/logs -v $PWD/data:/mysql_data -e MYSQL_ROOT_PASSWORD=1qazxsw2 -d mysql:latest
報(bào)錯(cuò)了
/usr/bin/docker-current: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting \\\"/alidata/docker/mysql/conf/my.cnf\\\" to rootfs \\\"/var/lib/docker/devicemapper/mnt/acdbb966c6c792749c0f8ae5cf1dd93bf52470a88bd83c3f05777b8151220703/rootfs\\\
z" at \\\"/var/lib/docker/devicemapper/mnt/acdbb966c6c792749c0f8ae5cf1dd93bf52470a88bd83c3f05777b8151220703/rootfs/etc/mysql/mysql.cnf\\\" caused \\\"not a directory\\\"\""\n".
參考http://www.docker.org.cn/thread/13.html
- 國內(nèi)daocloud鏡像
docker pull daocloud.io/library/mysql:5.7
Trying to pull repository daocloud.io/library/mysql ...
5.7: Pulling from daocloud.io/library/mysql
693502eb7dfb: Pull complete
08d0e9d74b1b: Pull complete
e700ebfbe6bc: Pull complete
f718f1976629: Pull complete
575a0830e278: Pull complete
8461dfcf361d: Pull complete
349434898dfb: Pull complete
78d351522443: Pull complete
21897ab46952: Pull complete
ca6ffbbedc10: Pull complete
ba8ff064032b: Pull complete
Digest: sha256:cd3b13f2a52d933ec6428911a500040167be2740cf687e9714c8b50df208c4f3
docker run -p 3306:3306 --name mymysql -v $PWD/conf/my.cnf:/etc/mysql/my.cnf -v $PWD/logs:/logs -v $PWD/data:/mysql_data -e MYSQL_ROOT_PASSWORD=1qazxsw2 -d mysql:5.7
cd3b13f2a52d933ec6428911a500040167be2740cf687e9714c8b50df208c4f3