jonashellmann / everydocs-core

A simple Document Management System for private use with basic functionality to organize your documents digitally
GNU General Public License v3.0
218 stars 15 forks source link

Docker run MySQL issue #14

Closed nickm324 closed 2 years ago

nickm324 commented 2 years ago

Every time I try and run the container I keep getting errors. Have a MySql running in a container using BRIDGE network. It has /var/lib/mysql/mysql.sock for MYSQL_UNIX_PORT.

rake aborted! ActiveRecord::ConnectionNotEstablished: Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2) /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/mysql2_adapter.rb:53:in rescue in new_client' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/mysql2_adapter.rb:43:innew_client' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/mysql2_adapter.rb:23:in mysql2_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:inpublic_send' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in new_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:incheckout_new_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in try_to_checkout_new_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:inacquire_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in checkout' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:inconnection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in retrieve_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_handling.rb:313:inretrieve_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_handling.rb:280:in connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/tasks/database_tasks.rb:262:inmigrate' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/railties/databases.rake:92:in block (2 levels) in <top (required)>' /usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in<top (required)>'

Caused by: Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2) /usr/local/bundle/gems/mysql2-0.5.4/lib/mysql2/client.rb:95:in connect' /usr/local/bundle/gems/mysql2-0.5.4/lib/mysql2/client.rb:95:ininitialize' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/mysql2_adapter.rb:44:in new' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/mysql2_adapter.rb:44:innew_client' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/mysql2_adapter.rb:23:in mysql2_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:inpublic_send' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in new_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:incheckout_new_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in try_to_checkout_new_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:inacquire_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in checkout' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:inconnection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in retrieve_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_handling.rb:313:inretrieve_connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/connection_handling.rb:280:in connection' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/tasks/database_tasks.rb:262:inmigrate' /usr/local/bundle/gems/activerecord-7.0.3.1/lib/active_record/railties/databases.rake:92:in block (2 levels) in <top (required)>' /usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in<top (required)>' Tasks: TOP => db:migrate

jonashellmann commented 2 years ago

I am very sorry that I am only now seeing your message.

I have my containers running in a Docker Compose network and for EVERYDOCS_DB_HOST I enter the name of the service where the database is running. I have not had any problems with this so far.

Therefore, I would suspect that you might use the wrong value for the database host or the database may not be accessible from another container via the specified port because the port may not be shared. According to the error message the connection to the database already fails..

AeliusSaionji commented 1 year ago

Typically, the end user expects a docker image to "just work" - if your system requires a database to run, that should be pulled in automatically.

jonashellmann commented 1 year ago

Typically, the end user expects a docker image to "just work" - if your system requires a database to run, that should be pulled in automatically.

Thank you for the comment! I'll make sure to add a docker-compose file that includes a database and everything needed to make the application running soon. When just using the Docker container, I'm not sure whether it is the right way to include a database in the same container.