docker-images/pluie/alpine-mysql/README.md

65 lines
1.5 KiB
Markdown
Raw Normal View History

2016-07-28 13:26:22 +00:00
# pluie/alpine-mysql
2016-07-28 15:46:03 +00:00
Extend pluie/alpine with mysql (mariadb) 5.5.47
2016-07-28 13:26:22 +00:00
2016-07-28 15:46:03 +00:00
## Image Size
2016-07-28 13:26:22 +00:00
2016-07-29 13:25:39 +00:00
- image ~ 172 MB
2016-07-28 13:26:22 +00:00
2016-07-28 15:46:03 +00:00
## Image Volumes
2016-07-28 13:26:22 +00:00
__/var/lib/mysql__ : mysql database directory
__/dump__ : directory to store various mysql scripts
2016-07-28 15:46:03 +00:00
## ENV variables
2016-07-28 13:26:22 +00:00
__MYSQL_DATABASE__ : create specified database at startup
__MYSQL_USER__ : create specified user at startup (and grant all rights to __MYSQL_DATABASE__)
__MYSQL_PASSWORD__
__MYSQL_ROOT_PASSWORD__ : don't really need it. a random root password is generated if none
2016-07-28 15:46:03 +00:00
## Image Usage
2016-07-28 13:26:22 +00:00
```
2016-07-29 09:48:56 +00:00
$ docker run --name mysql -p 3306 -v /home/docker/db/mysql:/var/lib/mysql -v /home/docker/db/dump:/dump -e MYSQL_DATABASE=mybase -e MYSQL_USER=dev -e MYSQL_PASSWORD=mysql -it pluie/alpine-mysql
2016-07-28 13:26:22 +00:00
```
2016-07-28 15:46:03 +00:00
### Root Usage
2016-07-28 13:26:22 +00:00
a root user is created at startup (if database directory is empty)
root login is permit only on localhost
to do things without files you can run :
```
$ docker exec -it mysql "mysql -uroot"
```
to do things with files you can log in to container :
```
docker exec -it mysql bash
```
then
```
$ mysql -uroot mybase < /dump/mydump.sql
```
etc.
2016-07-28 15:46:03 +00:00
### User usage
2016-07-28 13:26:22 +00:00
locally (on host) you can run (with appropriate user : pass) :
```
mysql -h ipmysqlcontainer -udev -pmysql
```
2016-07-28 13:28:31 +00:00
or if you want use the mysql client of the container :
2016-07-28 13:26:22 +00:00
```
docker exec -it mysql "mysql -h ipmysqlcontainer -udev -pmysql"
```
2016-07-28 15:46:03 +00:00
## Link Container
2016-07-28 13:26:22 +00:00
2016-07-28 13:28:31 +00:00
to link this container to another, use the default docker behavior :
2016-07-28 13:26:22 +00:00
```
docker run --name mycontainer --link mysql:db ...
```