2017-11-24 10:19:15 +08:00
|
|
|
## [MySQL](https://store.docker.com/images/mysql/)
|
2016-12-10 17:00:25 +08:00
|
|
|
|
|
|
|
### 基本信息
|
2017-11-24 10:19:15 +08:00
|
|
|
|
2016-12-10 17:00:25 +08:00
|
|
|
[MySQL](https://en.wikipedia.org/wiki/MySQL) 是开源的关系数据库实现。
|
|
|
|
|
2017-11-24 10:19:15 +08:00
|
|
|
该仓库位于 https://store.docker.com/images/mysql/ ,提供了 MySQL 5.5 ~ 8.x 各个版本的镜像。
|
2016-12-10 17:00:25 +08:00
|
|
|
|
|
|
|
### 使用方法
|
2017-11-24 10:19:15 +08:00
|
|
|
|
2016-12-10 17:00:25 +08:00
|
|
|
默认会在 `3306` 端口启动数据库。
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
```bash
|
2016-12-10 17:00:25 +08:00
|
|
|
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql
|
|
|
|
```
|
2017-11-24 10:19:15 +08:00
|
|
|
|
2016-12-10 17:00:25 +08:00
|
|
|
之后就可以使用其它应用来连接到该容器。
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
```bash
|
2016-12-10 17:00:25 +08:00
|
|
|
$ docker run --name some-app --link some-mysql:mysql -d application-that-uses-mysql
|
|
|
|
```
|
2017-11-24 10:19:15 +08:00
|
|
|
|
2016-12-10 17:00:25 +08:00
|
|
|
或者通过 `mysql`。
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
```bash
|
2017-12-01 17:32:39 +08:00
|
|
|
$ docker run -it --rm \
|
|
|
|
--link some-mysql:mysql \
|
|
|
|
mysql \
|
|
|
|
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
|
2016-12-10 17:00:25 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### Dockerfile
|
2017-02-07 22:04:05 +08:00
|
|
|
|
2017-11-01 00:36:57 +08:00
|
|
|
请到 https://github.com/docker-library/docs/tree/master/mysql 查看
|