Reputation: 143
While trying to run a MongoDB docker instance with authorization managed by docker-secrets (with files), inspired by this blog post, I kept running into the following error:
2020-07-24T16:25:26.656+0000 E QUERY [js] uncaught exception: Error: couldn't add user: Error preflighting normalization: U_STRINGPREP_PROHIBITED_ERROR :
# docker-compose.yml
version: '3.5'
services:
my_db:
image: mongo
command: --auth
environment:
MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/mongodb_root_password
MONGO_INITDB_ROOT_USERNAME_FILE: /run/secrets/mongodb_root_username
secrets:
- mongodb_root_password
- mongodb_root_username
secrets:
mongodb_root_password:
- file: mongodb/.mongodb_root_password
mongodb_root_username:
- file: mongodb/.mongodb_root_username
$ docker stack deploy --compose-file=docker-compose.yml my_db_stack
Unfortunately, the container kept dying. In the logs, I was able to find the error mentioned above.
Upvotes: 3
Views: 2050
Reputation: 143
It turns out that the problem was caused by Windows-style line endings in the mongodb/.mongodb_root_password
and mongodb/.mongodb_root_username
files. Those files were created on the Windows host, and then (I assume) were blindly copied to the container.
Using notepad++ I switched the line endings to Unix-style, which solved the problem.
To switch the line endings, I right-clicked the highlighted portion of the bottom bar in the image below, on Notepad++.
Upvotes: 3