Sign inSign up

mosaicgreifswald/mysql

By mosaicgreifswald

Updated 3 days ago

A difference: this MySQL image processes SQL files via the volume for and after initialization.

Image
Databases & storage
0

1.6K

mosaicgreifswald/mysql repository overview

General

This layer can be used to build a MySQL image, but also to add a database to our WildFly image. One difference to the official MySQL image is the ability to process sql files via the SQL mount even after initialization.

Relevant ENV Variables

CategoryVaraibleAvailable values or schemeDefault
SecurityMYSQL_ROOT_PASSWORD<STRING>root
LoggingMYSQL_GENERAL_LOG0, 10
LoggingMYSQL_SLOW_QUERY_LOG0, 10
OptimizingMYSQL_OPTS<STRING>-
UpdatingMYSQL_UPDATE_SCANNER_ENABLEDtrue | falsefalse
UpdatingMYSQL_UPDATE_SCANNER_INTERVAL<NUMBER>30

The variable MYSQL_OPTS in particular is comparable to JAVA_OPTS, where additional parameters can be specified that are to be taken into account when MySQL is started. For example, the memory requirement can simply be specified with: MYSQL_OPTS=--innodb_buffer_pool_size=10G.

Relevant Entrypoints

Pathref. ENV-VariableType (Permission)Purpose
/entrypoint-mysql-sqlsENTRY_MYSQL_SQLSdirectory (r)All SQL-files that are to be executed at the first start for database preparation are placed here.
/entrypoint-mysql-update-sqlsENTRY_MYSQL_UPDATE_SQLSdirectory (r/w)Is only required if MYSQL_UPDATE_SCANNER_ENABLED=true, then all SQL-files that are stored here are imported during operation.
/entrypoint-mysql-dataENTRY_MYSQL_DATADIRdirectory (r/w)This directory can be mounted in an external volume so that data is not lost after delete container.
/entrypoint-mysql-my-cnfENTRY_MYSQL_MY_CNFfile (r)The my.cnf file contains all settings that are relevant for the operation of the MySQL-database and can be exchanged accordingly.
/entrypoint-mysql-socketENTRY_MYSQL_SOCKETdirectory (r/w)The MySQL-socket is only relevant for accessing the database if no port is available.
/entrypoint-mysql-logsENTRY_MYSQL_LOGSSymlink (r/w)All logs generated by the MySQL service are stored here.

Usage Docker

# build java-image
> git clone https://github.com/mosaic-hgw/Docker.git
> cd mosaic-hgw/Docker/image/mysql
> docker build --tag="mosaicgreifswald/mysql" --file="Dockerfile.mysql.8" .

# "versions" shows all installed tools and components, with their versions
> docker run --rm mosaicgreifswald/mysql versions
  last updated               : 2026-05-20 08:53:46
  Architecture               : x86_64
  Distribution               : Debian GNU/Linux 13.5 (trixie)
  MySQL-Server               : 8.4.9
  
# "entrypoints" lists all registered entrypoints
> docker run --rm mosaicgreifswald/mysql entrypoints
  ENTRY_LOGS                   : /entrypoint-logs
  ENTRY_MYSQL_DATADIR          : /entrypoint-mysql-data
  ENTRY_MYSQL_SQLS             : /entrypoint-mysql-sqls
  ENTRY_MYSQL_UPDATE_SQLS      : /entrypoint-mysql-update-sqls
  ENTRY_MYSQL_MY_CNF           : /entrypoint-mysql-my-cnf
  ENTRY_MYSQL_SOCKET           : /entrypoint-mysql-socket
  ENTRY_MYSQL_LOGS             : /entrypoint-mysql-logs

# simple start with your init-sqls and mysql-configuration, as well as locally stored db-data and logs
> docker run --rm -it \
    -e MYSQL_ROOT_PASSWORD=top-secret \
    -p 3306:3306 \
    -v /path/to/your/db-data:/entrypoint-mysql-data \
    -v /path/to/your/sqls:/entrypoint-mysql-sqls \
    -v /path/to/your/update-sqls:/entrypoint-mysql-update-sqls \
    -v /path/to/your/my.cnf:/entrypoint-mysql-my-cnf \
    -v /path/to/your/logs:/entrypoint-mysql-logs \
    mosaicgreifswald/mysql

Change write permissions

If data is stored on the host-system (via volume), it is created by default with the internal mosaic-user (UID:GID = 1111:1111). Accordingly, the writable directories on the host-system must be unlocked for the mosaic-user.

# at host-system
chown -R 1111:1111 db-data logs
The alternative, change write-user

You can change the write-user by using the Docker parameter --user/-u.

# change write-user (UID:GID) for writable volumes
> mkdir /path/to/your/db-data
> chown 1006:1001 /path/to/your/db-data
> docker run --rm -d -u 1006:1001 -v /path/to/your/db-data:/entrypoint-mysql-data mosaicgreifswald/mysql

> ls -la /path/to/your/db-data
insgesamt 104552
drwxr-xr-x  7 1006 1001     4096  9. Jun 10:29  .
drwxrwxrwt 10 root root     4096  9. Jun 10:29  ..
-rw-r-----  1 1006 1001     1553  9. Jun 10:29  224fec23b202.err
-rw-r-----  1 1006 1001        4  9. Jun 10:29  224fec23b202.pid
-rw-r-----  1 1006 1001       56  9. Jun 10:29  auto.cnf
-rw-r-----  1 1006 1001      867  9. Jun 10:29  binlog.000001
-rw-r-----  1 1006 1001      158  9. Jun 10:29  binlog.000002
-rw-r-----  1 1006 1001       32  9. Jun 10:29  binlog.index
-rw-------  1 1006 1001     1705  9. Jun 10:29  ca-key.pem
...

Usage with Docker compose

# docker-compose.yml
services:
  mysql:
    image: mosaicgreifswald/mysql
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: top-secret
    volumes:
      - ./db-data:/entrypoint-mysql-data
      - ./sqls:/entrypoint-mysql-sqls
      - ./update-sqls:/entrypoint-mysql-update-sqls
      - ./my.cnf:/entrypoint-mysql-my-cnf
      - ./logs:/entrypoint-mysql-logs

Additional files

# explore all additional files
> docker run --rm -it mosaicgreifswald/mysql examples

# explore and copy interesting files to your local host
> docker run --rm -itv "/your/local/path/:/tmp/" mosaicgreifswald/mysql examples --target-dir /tmp

# or copy directly all files to your host
> docker run --rm -v "/your/local/path/:/tmp/" mosaicgreifswald/mysql examples --copy-all --target-dir /tmp"

You will receive the following directory-tree and can start playing immediately:

├─┬─ layer-readme/
│ ├─── README-debian.md
│ └─── README-mysql.md
└─┬─ examples/
  ├─┬─ compose-mysql-empty/
  │ ├─── db-data/
  │ ├─┬─ envs/
  │ │ └─── ttp_mysql.env
  │ ├─── logs/
  │ ├─── sqls/
  │ ├─── update-sqls/
  │ ├─── my.cnf
  │ └─── docker-compose.yml
  └─┬─ pure-envs/
    ├─── debian.env
    └─── ttp_mysql.env

Current Software-Versions on this Image

DateTagsChanges
2026-05-20

8.4.9, 8 (Dockerfile)

Debian 13.5 "trixie"
MySQL-Server 8.4.9
2026-04-22

9.7.0, 9, latest (Dockerfile)

Debian 12.11 "bookworm"
MySQL-Server 9.7.0
2025-07-22

8.4.6 (Dockerfile)

Debian 12.11 "bookworm"
MySQL-Server 8.4.6
2025-07-07

8.4.4 (Dockerfile)

Debian 12.11 "bookworm"
MySQL-Server 8.4.4
2025-01-13



8.4.3 (Dockerfile)



Debian 12.9 "bookworm"
MySQL-Server 8.4.3
added support for docker-parameter --user/-u
added sql-update-strategy
2024-09-09

8.4.2 (Dockerfile)

Debian 12.7 "bookworm"
MySQL-Server 8.4.2
2024-07-22

8.4.1 (Dockerfile)

Debian 12.6 "bookworm"
MySQL-Server 8.4.1
2024-06-188.4.0 (Dockerfile)MySQL-Server 8.4.0
2024-03-05

8.3.0 (Dockerfile)

Debian 12.5 "bookworm"
MySQL-Server 8.3.0

Tag summary

Content type

Image

Digest

sha256:c2cb89a8e

Size

191.7 MB

Last updated

3 days ago

docker pull mosaicgreifswald/mysql