13 Commits

Author SHA1 Message Date
Asif Bacchus 09752089d6 update labels, bump version number 2021-05-12 21:33:59 -06:00
Asif Bacchus e4ea780a12 fix(entrypoint): only show passwd if generated 2021-05-12 20:55:55 -06:00
Asif Bacchus 0fb3dd427c Revert "fix(entrypoint): fix missing db name for SQL import"
This reverts commit 1630094cf7.
2021-05-01 08:15:49 -06:00
Asif Bacchus 1630094cf7 fix(entrypoint): fix missing db name for SQL import 2021-05-01 07:56:44 -06:00
Asif Bacchus ee29f71ff0 chore: remove VSCode files 2021-05-01 07:00:15 -06:00
Asif Bacchus 7f930e17e7 feature: bump Alpine and MariaDB versions
- Alpine to 3.13
- MariaDB to 10.5.9
2021-05-01 06:59:20 -06:00
Asif Bacchus 2b7c54ead7 docs(README): fix wrong repo name 2021-01-05 16:49:31 -07:00
Asif Bacchus be539440e4 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2021-01-05 16:45:38 -07:00
Asif Bacchus 93b1212676 docs(README): use dockerhub as primary reference 2021-01-05 16:41:49 -07:00
Asif Bacchus 402e5217a3 docs(README): use dockerhub as primary reference 2021-01-05 16:39:20 -07:00
Asif Bacchus 797777d547 chore(LABELS): revert incorrect label change
mariadb version was correct previously
2021-01-05 16:12:02 -07:00
Asif Bacchus c689d210b9 chore(GIT): track rider workspace settings 2021-01-05 15:48:44 -07:00
Asif Bacchus 086fdf8479 chore(LABELS): update label info 2021-01-05 15:48:13 -07:00
9 changed files with 82 additions and 36 deletions
-3
View File
@@ -9,6 +9,3 @@
# Local History for Visual Studio Code
.history/
# Rider configuration files
.idea/
+13
View File
@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/projectSettingsUpdater.xml
/contentModel.xml
/modules.xml
/.idea.ab-mariadb-alpine.iml
# Datasource local storage ignored files
/../../../../../../../../../:\Users\AsifB\Documents\RiderProjects\ab-mariadb-alpine\.idea\.idea.ab-mariadb-alpine.dir\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelUserStore">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RIDER_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/../.." />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CommitMessageInspectionProfile">
<profile version="1.0">
<inspection_tool class="BodyLimit" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SubjectBodySeparation" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SubjectLimit" enabled="true" level="ERROR" enabled_by_default="true" />
</profile>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
-3
View File
@@ -1,3 +0,0 @@
{
"bookmarks": []
}
+8 -7
View File
@@ -2,16 +2,16 @@
### mariadb running on Alpine Linux
#
FROM alpine:3.12
FROM alpine:3.13
# standardized labels
LABEL maintainer="Asif Bacchus <asif@bacchus.cloud>"
LABEL org.label-schema.cmd="docker run -d --name db -v volume:/var/lib/mysql [-v /pre/exec/scripts:/docker-entrypoint-preinit.d] [-v /sql/scripts:/docker-entrypoint-initdb.d] [-v /post/exec/scripts:/docker-entrypoint-postinit.d] [-e TZ=Etc/UTC -e MYSQL_UID=8100 -e MYSQL_GID=8100 -e MYSQL_ROOT_PASSWORD=... -e MYSQL_DATABASE='myData' -e MYSQL_CHARSET='utf8mb4' -e MYSQL_COLLATION='utf8mb4_general_ci' -e MYSQL_USER=... -e MYSQL_PASSWORD=...] docker.asifbacchus.app/mariadb/ab-mariadb-alpine:latest"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.docker.cmd="docker run -d --name db -v volume:/var/lib/mysql [-v /pre/exec/scripts:/docker-entrypoint-preinit.d] [-v /sql/scripts:/docker-entrypoint-initdb.d] [-v /post/exec/scripts:/docker-entrypoint-postinit.d] [-e param1 -e param2...] docker.asifbacchus.app/mariadb/ab-mariadb-alpine:latest"
LABEL org.label-schema.description="mariadb running on Alpine Linux."
LABEL org.label-schema.name="ab-mariadb-alpine"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.url="https://git.asifbacchus.app/ab-docker/ab-mariadb-alpine"
LABEL org.label-schema.usage="https://git.asifbacchus.app/ab-docker/ab-mariadb-alpine/wiki"
LABEL org.label-schema.usage="https://git.asifbacchus.app/ab-docker/ab-mariadb-alpine/src/branch/master/README.md"
LABEL org.label-schema.vcs-url="https://git.asifbacchus.app/ab-docker/ab-mariadb-alpine.git"
# install mariadb and turn on TCP connection in default config
@@ -51,8 +51,9 @@ RUN mkdir -p /docker-entrypoint-preinit.d \
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
CMD [ "/usr/bin/mysqld", "--user=mysql", "--console" ]
# add build date and version labels
# add parameters, version and build date labels
LABEL org.label-schema.docker.params="TZ=Etc/UTC, MYSQL_UID=8100, MYSQL_GID=8100, MYSQL_ROOT_PASSWORD=..., MYSQL_DATABASE='myData', MYSQL_CHARSET='utf8mb4', MYSQL_COLLATION='utf8mb4_general_ci', MYSQL_USER=..., MYSQL_PASSWORD=..."
LABEL org.label-schema.vendor="mariaDB (10.5.9-r0)"
LABEL org.label-schema.version="1.1"
ARG BUILD_DATE
LABEL org.label-schema.build-date=${BUILD_DATE}
LABEL org.label-schema.vendor="mariaDB (10.5.8-r0)"
LABEL org.label-schema.version="1.0"
+26 -20
View File
@@ -1,6 +1,9 @@
# MariaDB on Alpine Linux (dockerized)
Fully functional dockerized installation of MariaDB server and client running on Alpine Linux. This container is roughly half the size of the official MariaDB container which runs on Ubuntu but still aims to mimic all its features while adding a few extra ;-)
Fully functional dockerized installation of MariaDB server and client running on Alpine Linux. This container is roughly
half the size of the official MariaDB container which runs on Ubuntu but still aims to mimic all its features while
adding a few extra ;-) Note that this container is built against the Alpine EDGE repository for newer versions of
mariaDB.
- [Quick Start](#quick-start)
- [Pull the image](#pull-the-image)
@@ -37,11 +40,12 @@ Fully functional dockerized installation of MariaDB server and client running on
### Pull the image
The latest images are on my private Docker Repo but I also try to keep the ones on Dockerhub updated within a few days. As such, you have two choices:
The latest images are on my private docker registry but, I also try to keep the ones on Dockerhub updated within a few
days. If you need signed containers, you will have to use my private registry. As such, you have two choices:
```bash
# my private repo
docker pull docker.asifbacchus.app/mariadb/ab-mariadb-alpine:latest
docker pull asifbacchus/ab-mariadb-alpine:latest
```
or
@@ -51,7 +55,9 @@ or
docker pull asifbacchus/ab-mariadb-alpine:latest
```
All the examples in this document will refer to my repo, but you can use Dockerhub if you prefer.
The examples in this document will refer to dockerhub, but know that anywhere you
see `asifbacchus/ab-mariadb-alpine:tag` you can use `docker.asifbacchus.app/mariadb/ab-mariadb-alpine` to use my
registry instead.
### Run the image
@@ -64,7 +70,7 @@ docker run -d \
-e MYSQL_DATABASE='CompanyX' \
-e MYSQL_USER='JaneDoe' \
-e MYSQL_PASSWORD='JanesPa$$w0rd' \
docker.asifbacchus.app/mariadb/ab-mariadb-alpine
asifbacchus/ab-mariadb-alpine
```
Let's take a quick overview of the options used above:
@@ -74,7 +80,7 @@ Let's take a quick overview of the options used above:
Assuming an existing database does not exist in the container's data directory already, it will create an empty database for you. The name of this database is controlled by the environment variable `MYSQL_DATABASE`. This defaults to 'myData'. If you would like to create a database called 'CompanyX', for example, you would set the environment variable as follows:
```bash
docker run -d -e MYSQL_DATABASE='CompanyX' docker.asifbacchus.app/mariadb/ab-mariadb-alpine
docker run -d -e MYSQL_DATABASE='CompanyX' asifbacchus/ab-mariadb-alpine
```
#### Root password
@@ -84,7 +90,7 @@ If you do not set a root password for mySQL, the container will generate one for
In normal usage, you will want to set the root password instead of having it generated for you. This is accomplished by setting the environment variable `MYSQL_ROOT_PASSWORD`. The command would look something like:
```bash
docker run -d -e MYSQL_ROOT_PASSWORD='SuPeR$ecurEP@$$w0rd' docker.asifbacchus.app/mariadb/ab-mariadb-alpine
docker run -d -e MYSQL_ROOT_PASSWORD='SuPeR$ecurEP@$$w0rd' asifbacchus/ab-mariadb-alpine
```
#### User password
@@ -92,7 +98,7 @@ docker run -d -e MYSQL_ROOT_PASSWORD='SuPeR$ecurEP@$$w0rd' docker.asifbacchus.ap
If you would like a user account created for you with FULL privileges to the database created by the container, you must set two environment variables: `MYSQL_USER` and `MYSQL_PASSWORD`. You can do that as follows:
```bash
docker run -d -e MYSQL_USER='JaneDoe' -e MYSQL_PASSWORD='JanesPa$$w0rd' docker.asifbacchus.app/mariadb/ab-mariadb-alpine
docker run -d -e MYSQL_USER='JaneDoe' -e MYSQL_PASSWORD='JanesPa$$w0rd' asifbacchus/ab-mariadb-alpine
```
## Connecting as a client
@@ -114,7 +120,7 @@ This will log you into the container using the root account and connect you to M
You can launch another instance of the container and use that as a client to connect to your server container or any other remote MariaDB/mySQL instance. In this case, we don't want to pass any environment variables, but we want to pass a separate CMD parameter as follows:
```bash
docker run -it --rm docker.asifbacchus.app/mariadb/ab-mariadb-alpine mysql -hmysql.host.tld -uusername -ppassword
docker run -it --rm asifbacchus/ab-mariadb-alpine mysql -hmysql.host.tld -uusername -ppassword
```
**N.B.* I used the `--rm` Docker parameter to automatically remove the container on exit. This is optional.
@@ -194,10 +200,10 @@ By default, the container will create a volume to store your mySQL database so y
```bash
# create a volume or use an existing named-volume
docker run -d -v mydatabase:/var/lib/mysql docker.asifbacchus.app/mariadb/ab-mariadb-alpine
docker run -d -v mydatabase:/var/lib/mysql asifbacchus/ab-mariadb-alpine
# use a bind-mount location
docker run -d -v /my/local/dir:/var/lib/mysql docker.asifbacchus.app/mariadb/ab-mariadb-alpine
docker run -d -v /my/local/dir:/var/lib/mysql asifbacchus/ab-mariadb-alpine
```
## Data instantiation/import
@@ -207,7 +213,7 @@ docker run -d -v /my/local/dir:/var/lib/mysql docker.asifbacchus.app/mariadb/ab-
The entrypoint script of the container simply checks to see if the */var/lib/mysql* directory is empty and, if so, creates a new database for you. Thus, if you want to import an existing database, you simply have to mount a valid *mysql* subdirectory:
```bash
docker run -d -v /existing/mysql:/var/lib/mysql docker.asifbacchus.app/mariadb/ab-mariadb-alpine
docker run -d -v /existing/mysql:/var/lib/mysql asifbacchus/ab-mariadb-alpine
```
### Instantiation
@@ -215,13 +221,13 @@ docker run -d -v /existing/mysql:/var/lib/mysql docker.asifbacchus.app/mariadb/a
If you want to 'instantiate' your newly created database (add tables, some default data, set privileges, etc.) then you can import SQL files with commands preloaded. Any *.sql* or *.sql.gz* files mounted in the container's */docker-entrypoint-initdb.d* folder will be imported after the new database is created.
```bash
docker run -d -v /sql/import/scripts:/docker-entrypoint-initdb.d docker.asifbacchus.app/mariadb/ab-mariadb-alpine
docker run -d -v /sql/import/scripts:/docker-entrypoint-initdb.d asifbacchus/ab-mariadb-alpine
```
You should review the logs when doing this to see if MariaDB throws any errors due to syntax errors or other mistakes in your SQL files. An easy way to do this is:
```bash
docker run -d --name db -v /sql/import/scripts:/docker-entrypoint-initdb.d docker.asifbacchus.app/mariadb/ab-mariadb-alpine && docker logs -f db
docker run -d --name db -v /sql/import/scripts:/docker-entrypoint-initdb.d asifbacchus/ab-mariadb-alpine && docker logs -f db
```
You can, of course, name your container anything you like. Just change *'db'* in both places to whatever you choose.
@@ -238,7 +244,7 @@ To run scripts after MariaDB is initialized (i.e. after a database is created an
docker run -d \
-v /my/pre-init/scripts:/docker-entrypoint-preinit.d \
-v /my/post-init/scripts:/docker-entrypoint-postinit.d \
docker.asifbacchus.app/mariadb/ab-mariadb-alpine
asifbacchus/ab-mariadb-alpine
```
### Entrypoint Task Order
@@ -267,7 +273,7 @@ For reference, the sequence of events in the entrypoint script is:
You can pass MariaDB command-line parameters to your container just as your would with a regular *mysqld* instance. For example:
```bash
docker run -d docker.asifbacchus.app/mariadb/ab-mariadb-alpine --innodb-ft-min-token-size=2
docker run -d asifbacchus/ab-mariadb-alpine --innodb-ft-min-token-size=2
```
The container will concatenate any parameters your supply with the default ones of *--console --user=mysql*. Note that command-line parameters override environment variable parameters supplied to the container.
@@ -280,12 +286,12 @@ If you would like to use a completely custom MariaDB configuration you will need
# custom my.cnf
docker run -d \
-v /mysql/configuration/my.cnf:/etc/my.cnf \
docker.asifbacchus.app/mariadb/ab-mariadb-alpine
asifbacchus/ab-mariadb-alpine
# custom server-related files
docker run -d \
-v /mysql/server-config:/etc/my.cnf.d \
docker.asifbacchus.app/mariadb/ab-mariadb-alpine
asifbacchus/ab-mariadb-alpine
# complex configuration using custom my.cnf
# this completely depends on how you specify things in my.cnf
@@ -293,7 +299,7 @@ docker run -d \
-v /mysql/config/my.cnf:/etc/my.cnf \
-v /mysql/other-config:/etc/mysql/some-directory \
-v /mysql/more-configs:/etc/mysql/cnf/another-dir \
docker.asifbacchus.app/mariadb/ab-mariadb-alpine
asifbacchus/ab-mariadb-alpine
```
You should be aware that the container passes *'--console --user=mysql'* command-line parameters to *mysqld* by default and that will override parameters specified in *my.cnf* or any other configuration file. If you need to override these defaults, you will have to pass the *mysqld* command manually:
@@ -301,7 +307,7 @@ You should be aware that the container passes *'--console --user=mysql'* command
```bash
docker run -d \
-v /mysql/configuration/my.cnf:/etc/my.cnf \
docker.asifbacchus.app/mariadb/ab-mariadb-alpine \
asifbacchus/ab-mariadb-alpine \
mysqld --user=anotheruser
```
+4
View File
@@ -19,6 +19,7 @@ isInt () {
# instantiate variables
sqlCmd='/tmp/cmd.sql'
showRootPassword=0
# convert env variables to uppercase for proper string comparison
MYSQL_SKIP_NAME_RESOLVE=$(convertCase "$MYSQL_SKIP_NAME_RESOLVE")
@@ -48,6 +49,7 @@ fi
if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
MYSQL_ROOT_PASSWORD="$( head /dev/urandom | tr -dc A-Za-z0-9 | head -c32 )"
export MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
showRootPassword=1
fi
# change mysql UID & GID
@@ -159,7 +161,9 @@ done
# note initialization complete and display root password
printf "\nInitialization complete...\n"
if [ "$showRootPassword" -eq 1 ]; then
printf "(mySQL root password: %s)\n\n" "$MYSQL_ROOT_PASSWORD"
fi
# process CMD sent to this container
case "$1" in