🐛fix(): fix bug add docker-compose
Signed-off-by: ehlxr <ehlxr.me@gmail.com>
This commit is contained in:
parent
924b7874c4
commit
4ebec1bde5
@ -2,7 +2,7 @@ FROM alpine:latest
|
|||||||
LABEL maintainer="ehlxr.me@gmail.com"
|
LABEL maintainer="ehlxr.me@gmail.com"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
VOLUME /app
|
VOLUME /data
|
||||||
|
|
||||||
RUN apk add --update --no-cache mysql mysql-client \
|
RUN apk add --update --no-cache mysql mysql-client \
|
||||||
&& rm -f /var/cache/apk/*
|
&& rm -f /var/cache/apk/*
|
||||||
|
@ -4,12 +4,24 @@ a docker image base on alpine with mysql
|
|||||||
# build image
|
# build image
|
||||||
```
|
```
|
||||||
docker build -t ehlxr/alpine-mysql .
|
docker build -t ehlxr/alpine-mysql .
|
||||||
docker run -it --rm -v $(pwd):/app -p 3306:3306 ehlxr/alpine-mysql
|
```
|
||||||
|
|
||||||
|
# build image (docker-compose)
|
||||||
|
|
||||||
|
```
|
||||||
|
docker-compose build
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
```
|
```
|
||||||
docker run -it --name mysql -p 3306:3306 -v $(pwd):/app -e MYSQL_DATABASE=admin -e MYSQL_USER=tony -e MYSQL_PASSWORD=dpa\*12d -e MYSQL_ROOT_PASSWORD=111111 ehlxr/alpine-mysql
|
docker run -it --name mysql -p 3306:3306 -v $(pwd)/db-data:/data -e MYSQL_DATABASE=admin -e MYSQL_USER=ehlxr -e MYSQL_PASSWORD=prY6KaQC -e MYSQL_ROOT_PASSWORD=eDWyvjS2 ehlxr/alpine-mysql
|
||||||
```
|
```
|
||||||
|
|
||||||
It will create a new db, and set mysql root password(default is 111111)
|
> It will create a new db(default is `admin`) whith user `ehlxr` set password is `prY6KaQC`, and set mysql root password(default is `#Q*2.&tY`)
|
||||||
|
|
||||||
|
# Usage (docker-compose)
|
||||||
|
```
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
> It will create a new db(default is `admin`) whith user `ehlxr` set password is `prY6KaQC`, and set mysql root password(default is `eDWyvjS2`)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[mysqld]
|
[mysqld]
|
||||||
user = root
|
user = root
|
||||||
datadir = /app/mysql
|
datadir = /data/mysql
|
||||||
port = 3306
|
port = 3306
|
||||||
log-bin = /app/mysql/mysql-bin
|
log-bin = /data/mysql/mysql-bin
|
@ -1,6 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -d /app/mysql ]; then
|
if [ ! -d "/run/mysqld" ]; then
|
||||||
|
mkdir -p /run/mysqld
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /data/mysql ]; then
|
||||||
echo "[i] MySQL directory already present, skipping creation"
|
echo "[i] MySQL directory already present, skipping creation"
|
||||||
else
|
else
|
||||||
echo "[i] MySQL data directory not found, creating initial DBs"
|
echo "[i] MySQL data directory not found, creating initial DBs"
|
||||||
@ -8,7 +12,7 @@ else
|
|||||||
mysql_install_db --user=root > /dev/null
|
mysql_install_db --user=root > /dev/null
|
||||||
|
|
||||||
if [ "$MYSQL_ROOT_PASSWORD" = "" ]; then
|
if [ "$MYSQL_ROOT_PASSWORD" = "" ]; then
|
||||||
MYSQL_ROOT_PASSWORD=111111
|
MYSQL_ROOT_PASSWORD=eDWyvjS2
|
||||||
echo "[i] MySQL root Password: $MYSQL_ROOT_PASSWORD"
|
echo "[i] MySQL root Password: $MYSQL_ROOT_PASSWORD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -16,10 +20,6 @@ else
|
|||||||
MYSQL_USER=${MYSQL_USER:-""}
|
MYSQL_USER=${MYSQL_USER:-""}
|
||||||
MYSQL_PASSWORD=${MYSQL_PASSWORD:-""}
|
MYSQL_PASSWORD=${MYSQL_PASSWORD:-""}
|
||||||
|
|
||||||
if [ ! -d "/run/mysqld" ]; then
|
|
||||||
mkdir -p /run/mysqld
|
|
||||||
fi
|
|
||||||
|
|
||||||
tfile=`mktemp`
|
tfile=`mktemp`
|
||||||
if [ ! -f "$tfile" ]; then
|
if [ ! -f "$tfile" ]; then
|
||||||
return 1
|
return 1
|
||||||
@ -47,5 +47,4 @@ EOF
|
|||||||
rm -f $tfile
|
rm -f $tfile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exec /usr/bin/mysqld --user=root --console
|
||||||
exec /usr/bin/mysqld --user=root --console
|
|
Loading…
Reference in New Issue
Block a user