Ok, so there was much work involved + much research:
- you must have separate MySQL container and containers using it
- docker-mailserver must use these lines instead of
image:
build:
context: .
dockerfile: Dockerfile
- Dockerfile must be:
FROM docker.io/mailserver/docker-mailserver:latest
RUN apt-get update && apt-get install -y dovecot-mysql
- as you can see it must be run with
docker-compose with --build parameter
dovecot-mysql must be installed as it is for plugin for getting password from MySQL database (this plugin must be enabled for roundcube in config file - to change passwords in database from roundcube)
- in
etc/dovecot/10-auth.conf you need to comment
!include auth-passwdfile.inc with #
- in the same file uncomment
#!include auth-sql.conf.ext
- in file
10-ssl.conf make line ssl=yes
- this may be needed for
userdb also
- make in your container database a table
mailbox with columns username, password
- add at least one user with password
$1$... - encrypted
dovecot.cf file must have ssl=yes and you may want to add disable_plaintext_auth=yes
- have
/etc/dovecot as volume (take the files from inside the container)
- in
/etc/dovecot/dovecot-sql.conf.ext have:
driver = mysql
connect = host=mail_mysql_cont dbname=db user=username password=root_passwd_for_db
password_query = \
SELECT username AS user, password \
FROM mailbox WHERE username = '%u'
user_query = \
SELECT '/tmp' AS home, 9999 AS uid, 9999 AS gid;
- in
/etc/dovecot/auth-sql.conf.ext have:
passdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}
I will update the answer later as I will work on the problem further.
EDIT:
To make password changing possible in Roundcube you need to have MySQL database attached and table mailbox created with at least columns username and password.