Docker compose upgrade from 1.x to 2.x can result in non-working Mailu
Versions
Mailu 1.8 Docker compose 2.0.1
Description
With the recent upgrade of Docker Compose from version 1.x to 2.x many things changed and it seems that this is also the case for the parser of the environment file. If there a spaces in some of the settings, docker compose will not start and will complain with "key cannot contain a space". For me this was the case with "WELCOME_SUBJECT" and "WELCOME_BODY" in the mailu.env file. A simple and straight forward solution was to put the settings into quotes. As these values were directly taken from the configurator this could affect new users. See also this issue here from docker compose: https://github.com/docker/compose/issues/8736
Replication Steps
Install the latest docker compose (2.0.1) and make an environment file with a setting which contain spaces.
Expected behaviour
"docker compose" should not complain about spaces in settings. Therefore all settings with spaces should be inside quotes.
Isn't this a new bug in docker compose (v2)? Where is it documented that you are not allowed to use spaces anymore in .env files? On the compose compatibility page it shows it should work exactly the same as docker-compose.
The problem is located in the .env file where spaces are no longer allowed in environment variables. The solution is to add double quotes around strings. However, this .env file is generated by the setup:
WELCOME_SUBJECT="Welcome to your new email account"
WELCOME_BODY="Welcome to your new email account, if you can read this, then it is configured properly!"
Random online articles are not good input. Only official documentation. After checking the compose project I could find a PR for the documentation. In this issue they also discuss that using spaces leads to issues. For docker compose v2 they switched to a new dotenv parser which introduced this breaking change in behaviour.
The documentation shows that you can use single quotes or double quotes for docker compose v2. But be warned! With docker-compose v1 there is no special handling of quotation marks in an dotenv file. This means that they are part of the VALUE. In the linked issue I also read that docker stack treats quotes as part of the value which leads to issues when combined with docker compose v2.
Using this might lead to issues, if you have other software that must also parse the same .env file.
We use python for processing all environment variables. I suspect python already strips the quotes and we can simply change the mailu.env template file to use quotes and update the documentation. This should be thoroughly tested.
We must also be careful that docker stack / docker swarm does not break when introducing quotes.
Looks like the issue in the dotenv parser is resolved. I'm closing this issue.