docker-bookstack icon indicating copy to clipboard operation
docker-bookstack copied to clipboard

[BUG] Container startup fails with special characters in passwords

Open GamerBene19 opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

I've tried setting up the container(s) with

container_name: bookstack_db
environment:
  - PUID=100000
  - PGID=100000
  - TZ=Europe/Berlin
  - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
  - MYSQL_DATABASE=bookstackapp
  - MYSQL_USER=bookstack
  - MYSQL_PASSWORD=${DB_PASS} # same ${DB_PASS} for bookstack container

and

user@host:~/docker-services/bookstack$ cat .env
# MySQL root password
MYSQL_ROOT_PASSWORD=g{#;'jh<u_9kVxqb}&4d
# Password of for bookstack database user
DB_PASS=E[Jt/2)n{'Q,&L;R"S*F

But with these passwords I encounter these two error message at container startup:

bookstack_db  | ERROR: 1064  You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'jh<u_9kVxqb}&4d' ;' at line 1
...
bookstack     | Failed to parse dotenv file. Encountered unexpected whitespace at ['E[Jt/2)n{'Q,&L;R"S*F'].

Expected Behavior

I understand the problem occurs because the environment variables are inserted into the config files 1:1. E.g.:

user@host:~/docker-services/bookstack$ docker compose exec webserver grep "DB_PASSWORD" /config/www/.env
DB_PASSWORD='E[Jt/2)n{'Q,&L;R"S*F'

I'd would be nice if there was a system automatically escape illegal characters, but I don't know if its feasible. Perhaps a check that prohibits the container from starting if these characters are detected is more realistic.

Steps To Reproduce

  1. Create .env file with above contents
  2. Create docker-compose.yml file (from template) with above enviornment options
  3. Try to start containers

Environment

No response

CPU architecture

x86-64

Docker creation

See docker-compose section above.

Container logs

See error messages above.

GamerBene19 avatar Oct 05 '24 21:10 GamerBene19

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

github-actions[bot] avatar Oct 05 '24 21:10 github-actions[bot]

If you're adding in special characters, you need to escape the whole ENV line with "

j0nnymoe avatar Oct 05 '24 22:10 j0nnymoe

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

LinuxServer-CI avatar Nov 05 '24 09:11 LinuxServer-CI

If you're adding in special characters, you need to escape the whole ENV line with "

Sorry forgot to reply. This was indeed the solution, I was just being dumb - thanks!

GamerBene19 avatar Nov 07 '24 07:11 GamerBene19

This issue is locked due to inactivity

github-actions[bot] avatar Dec 07 '24 09:12 github-actions[bot]