Description
Error Message and Logs
When deploying a MongoDB on MacOS in development, the following error occurs:
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /data/coolify/databases/zkgg04owwck0kw00800g84cg/docker-entrypoint-initdb.d
-> I think this only happens on MacOS because of the strict filesystem restrictions, but I could be wrong.
Steps to Reproduce
- Create a MongoDB on MacOS
- Start it
-> Discord thread: https://discord.com/channels/459365938081431553/1291781262016774198
Coolify Version
v4.0.0-beta.360
Additional Information
I investigated this Bug for a few hours today and found the following things.
- The following lines are causing the problem:
coolify/app/Actions/Database/StartMongodb.php
Lines 110 to 115 in 5d62a46
- If I replace these lines with the following one it works:
$docker_compose['services'][$container_name]['volumes'][] = "$this->configuration_dir/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro";
-> This approach uses the --volume syntax, which is more lenient in creating directories that don't exist (and it works), the other syntax with --mount is more strict, directory must exist for it to work. But when I check the directory is present in both scenarios.
Note I added one more line in addition to the commands to make sure the directory is present:
coolify/app/Actions/Database/StartMongodb.php
Lines 28 to 31 in 5d62a46
I added this line to the commands
"mkdir -p $this->configuration_dir/docker-entrypoint-initdb.d/",
Same thing happens for the Postgres config:
- These lines below do not work:
coolify/app/Actions/Database/StartPostgresql.php
Lines 110 to 115 in 5d62a46
- If I replace these lines with the following one it works:
$docker_compose['services'][$container_name]['volumes'][] = "$this->configuration_dir/custom-postgres.conf:/etc/postgresql/postgresql.conf:ro";
Why does the second option work in both cases and not the first? Ofc I could just change it everywhere to the second one which works and call it a day, but I would like to investigate and know why the first option does not seem to work.
EDIT:
-> It seems that the issue is docker bind mounts itself -> with the paths above it wants to bind mount the path on the host system but on dev we have a docker volume that needs to be mounted so bind mounts to the host do not work. We bind mount a path inside a docker volume inside a container - not sure why docker does not get that :). A dev fix (not pretty but works) was added here:
coolify/app/Actions/Database/StartMongodb.php
Lines 28 to 30 in 4ce8d04