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 :
Setup
- Windows machine running docker with a WSL2 backend.
- latest mongo image from docker hub (version 4.2.8)
- docker secrets to manage the authentication credentials to the MongoDB database
- my composer file:
# 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
- shell command to deploy docker stack
$ docker stack deploy --compose-file=docker-compose.yml my_db_stack
Problem
Unfortunately, the container kept dying. In the logs, I was able to find the error mentioned above.