Closed nickian closed 3 years ago
@nickian can you run the container without the -d
(daemon mode) and see paste what is the output of the logs?
It looks like it's a database issue.
Is it supposed to create its own new database within the container, or is it looking for a database on the host (outside of the containers).
Prestart Step 1/2 - Removing server lock
Prestart Step 2/2 - Migrating database
rake aborted!
Mysql2::Error: Can't connect to MySQL server on '127.0.0.1' (115)
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `connect'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `initialize'
/usr/local/bundle/gems/mysql2-reconnect_with_readonly-0.2.0/lib/mysql2/reconnect_with_readonly.rb:74:in `new'
/usr/local/bundle/gems/mysql2-reconnect_with_readonly-0.2.0/lib/mysql2/reconnect_with_readonly.rb:74:in `initialize'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `new'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `mysql2_connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:90:in `connection'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.4.4/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/syncing-server/lib/tasks/migrate_ignore_concurrent.rake:10:in `block (3 levels) in <main>'
/usr/local/bundle/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
The above was with running: docker run -d -p 3000:3000 --env-file=your-env-file standardnotes/syncing-server:stable
Then I tried running docker-compose up
instead and saw there was a permissions error on the database step. I changed the syncing-server repository permissions to 777 and did docker-compose up
and it worked! Not sure why or if this is expected behavior with permissions.
It's looking for a database under the same network as the container is.
Can you try adding --net=host
and see if that works? Your database has to be created and accessible under what is configured in .env
When I use that, the container stays running. However, I get this message:
WARNING: Published ports are discarded when using host network mode
And I can't access the server via my reverse proxy on port 3000 anymore.
Oh, wait. I take that back. It just took a couple of minutes to become available. That is working now!
Anything else you happened to do by chance? I have the following setup, but the container keeps restarting:
docker run --name standardnotes \
--net host \
--env-file=/standardnotes/.env \
--restart unless-stopped \
standardnotes/syncing-server:stable
On a side note, I'm noticing when I add a volume link through -v /standardnotes/data:/syncing-server \
, I'm seeing it's spit this error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "docker/entrypoint.sh": stat docker/entrypoint.sh: no such file or directory: unknown.
ERRO[0003] error waiting for container: context canceled
Last thing -- I have it set to host networking for my database as well as the image above, but to no avail with trying to fix the restart issue.
@hwittenborn I think this line --net host \
should be --net=host \
Still no luck, (edit)it appears to be restarting every 5 seconds or so
Still can't link that one folder without that last error showing up either
Update, it was a database connection issue -- don't know how I didn't notice it, but it's all running now, so I'm all good.
I'm glad to hear that! Thanks for letting us know!
Closing as this seems to be resolved. If any issues still occur feel free to reopen.
I'm trying to use the sync server with Docker, but the container keeps exiting immediately. I followed the steps here: https://docs.standardnotes.org/self-hosting/docker
Is there something I'm missing? Do I need to adjust any other settings in the
.env
file other than theSECRET_KEY_BASE
?Using docker-compose, the DB container runs fine, but not the sync server one. Running this results in the same thing:
docker run -d -p 3000:3000 --env-file=/path/to/.env standardnotes/syncing-server:stable
Any idea how I can troubleshoot what is going on here? Thanks.