Closed JeremiahChurch closed 9 months ago
Hi,
Did you modify anything in the .env
file or database.yml
config?
After upping the project what does docker compose ps
show?
Thanks for the reply!
Did you modify anything in the
.env
file ordatabase.yml
config?
no, sir - straight from the example - confirmed with another copy of the example just to be sure I didn't do something stupid (that's pretty common :)) here's a full fresh reboot of the host:
jchurch@ubuntu:~/hellorails$ cp .env.example .env
direnv: export +COMPOSE_PROFILES +COMPOSE_PROJECT_NAME +DOCKER_BUILDKIT +DOCKER_CABLE_PORT_FORWARD +DOCKER_RESTART_POLICY +DOCKER_WEB_HEALTHCHECK_TEST +DOCKER_WEB_PORT_FORWARD +DOCKER_WEB_VOLUME +NODE_ENV +POSTGRES_PASSWORD +POSTGRES_USER +RAILS_ENV +RAILS_MAX_THREADS +SECRET_KEY_BASE +WEB_CONCURRENCY
jchurch@ubuntu:~/hellorails$ docker compose up
[+] Running 7/0
✔ Container hellorails-redis-1 Created 0.0s
✔ Container hellorails-postgres-1 Created 0.0s
✔ Container hellorails-js-1 Created 0.0s
✔ Container hellorails-cable-1 Created 0.0s
✔ Container hellorails-web-1 Created 0.0s
✔ Container hellorails-worker-1 Created 0.0s
✔ Container hellorails-css-1 Created 0.0s
Attaching to hellorails-cable-1, hellorails-css-1, hellorails-js-1, hellorails-postgres-1, hellorails-redis-1, hellorails-web-1, hellorails-worker-1
hellorails-redis-1 | 1:C 13 Sep 2023 16:10:25.890 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
hellorails-redis-1 | 1:C 13 Sep 2023 16:10:25.890 # Redis version=7.0.12, bits=64, commit=00000000, modified=0, pid=1, just started
hellorails-redis-1 | 1:C 13 Sep 2023 16:10:25.890 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.891 * Increased maximum number of open files to 10032 (it was originally set to 1024).
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.891 * monotonic clock: POSIX clock_gettime
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 * Running mode=standalone, port=6379.
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 # Server initialized
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 * Loading RDB produced by version 7.0.12
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 * RDB age 48 seconds
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 * RDB memory usage when created 0.82 Mb
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 * Done loading RDB, keys loaded: 0, keys expired: 0.
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 * DB loaded from disk: 0.000 seconds
hellorails-redis-1 | 1:M 13 Sep 2023 16:10:25.892 * Ready to accept connections
hellorails-postgres-1 |
hellorails-postgres-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
hellorails-postgres-1 |
hellorails-postgres-1 |
hellorails-postgres-1 | 2023-09-13 16:10:26.040 UTC [1] LOG: starting PostgreSQL 15.4 (Debian 15.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
hellorails-postgres-1 | 2023-09-13 16:10:26.041 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
hellorails-postgres-1 | 2023-09-13 16:10:26.041 UTC [1] LOG: listening on IPv6 address "::", port 5432
hellorails-postgres-1 | 2023-09-13 16:10:26.042 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
hellorails-postgres-1 | 2023-09-13 16:10:26.045 UTC [29] LOG: database system was shut down at 2023-09-13 16:09:37 UTC
hellorails-postgres-1 | 2023-09-13 16:10:26.056 UTC [1] LOG: database system is ready to accept connections
yarn run v1.22.19
yarn run v1.22.19 |
$ ./run yarn:build
$ ./run yarn:build:css
hellorails-js-1 | [watch] build finished, watching for changes...
hellorails-cable-1 | [1] Puma starting in cluster mode...
hellorails-cable-1 | [1] * Puma version: 6.3.1 (ruby 3.2.2-p53) ("Mugi No Toki Itaru")
hellorails-cable-1 | [1] * Min threads: 1
hellorails-cable-1 | [1] * Max threads: 1
hellorails-cable-1 | [1] * Environment: development
hellorails-cable-1 | [1] * Master PID: 1
hellorails-cable-1 | [1] * Workers: 1
hellorails-cable-1 | [1] * Restarts: (✔) hot (✖) phased
hellorails-cable-1 | [1] * Preloading application
hellorails-css-1 |
hellorails-css-1 | Rebuilding...
hellorails-css-1 |
hellorails-css-1 | Done in 215ms.
hellorails-css-1 |
hellorails-web-1 | => Booting Puma
hellorails-web-1 | => Rails 7.0.7.2 application starting in development
hellorails-web-1 | => Run `bin/rails server --help` for more startup options
hellorails-web-1 | [1] Puma starting in cluster mode...
hellorails-web-1 | [1] * Puma version: 6.3.1 (ruby 3.2.2-p53) ("Mugi No Toki Itaru")
hellorails-web-1 | [1] * Min threads: 1
hellorails-web-1 | [1] * Max threads: 1
hellorails-web-1 | [1] * Environment: development
hellorails-web-1 | [1] * Master PID: 1
hellorails-web-1 | [1] * Workers: 1
hellorails-web-1 | [1] * Restarts: (✔) hot (✖) phased
hellorails-web-1 | [1] * Preloading application
hellorails-web-1 | [1] * Listening on http://0.0.0.0:8000
hellorails-web-1 | [1] Use Ctrl-C to stop
hellorails-web-1 | [1] ! WARNING: Detected running cluster mode with 1 worker.
hellorails-web-1 | [1] ! Running Puma in cluster mode with a single worker is often a misconfiguration.
hellorails-web-1 | [1] ! Consider running Puma in single-mode (workers = 0) in order to reduce memory overhead.
hellorails-web-1 | [1] ! Set the `silence_single_worker_warning` option to silence this warning message.
hellorails-web-1 | [1] - Worker 0 (PID: 11) booted in 0.0s, phase: 0
hellorails-worker-1 |
hellorails-worker-1 |
hellorails-worker-1 | m,
hellorails-worker-1 | `$b
hellorails-worker-1 | .ss, $$: .,d$
hellorails-worker-1 | `$$P,d$P' .,md$P"'
hellorails-worker-1 | ,$$$$$b/md$$$P^'
hellorails-worker-1 | .d$$$$$$/$$$P'
hellorails-worker-1 | $$^' `"/$$$' ____ _ _ _ _
hellorails-worker-1 | $: ',$$: / ___|(_) __| | ___| | _(_) __ _
hellorails-worker-1 | `b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
hellorails-worker-1 | $$: ___) | | (_| | __/ <| | (_| |
hellorails-worker-1 | $$ |____/|_|\__,_|\___|_|\_\_|\__, |
hellorails-worker-1 | .d$$ |_|
hellorails-worker-1 |
hellorails-worker-1 |
hellorails-worker-1 | 2023-09-13T16:10:28.295Z pid=1 tid=2pt INFO: Booted Rails 7.0.7.2 application in development environment
hellorails-worker-1 | 2023-09-13T16:10:28.296Z pid=1 tid=2pt INFO: Running in ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
hellorails-worker-1 | 2023-09-13T16:10:28.296Z pid=1 tid=2pt INFO: See LICENSE and the LGPL-3.0 for licensing details.
hellorails-worker-1 | 2023-09-13T16:10:28.296Z pid=1 tid=2pt INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
hellorails-worker-1 | 2023-09-13T16:10:28.296Z pid=1 tid=2pt INFO: Sidekiq 7.1.2 connecting to Redis with options {:size=>10, :pool_name=>"internal", :url=>"redis://redis:6379/1"}
hellorails-cable-1 | [1] * Listening on http://0.0.0.0:28080
hellorails-cable-1 | [1] ! WARNING: Detected 2 Thread(s) started in app boot:
hellorails-cable-1 | [1] ! #<Thread:0x00007f722c1eb220@DEBUGGER__::SESSION@server /usr/local/bundle/gems/debug-1.8.0/lib/debug/session.rb:179 sleep_forever> - <internal:thread_sync>:18:in `pop'
hellorails-cable-1 | [1] ! #<Rack::MiniProfiler::FileStore::CacheCleanupThread:0x00007f722b3241d8 /usr/local/bundle/gems/rack-mini-profiler-3.1.1/lib/mini_profiler/storage/file_store.rb:67 sleep> - /usr/local/bundle/gems/rack-mini-profiler-3.1.1/lib/mini_profiler/storage/file_store.rb:85:in `sleep'
hellorails-cable-1 | [1] Use Ctrl-C to stop
hellorails-cable-1 | [1] ! WARNING: Detected running cluster mode with 1 worker.
hellorails-cable-1 | [1] ! Running Puma in cluster mode with a single worker is often a misconfiguration.
hellorails-cable-1 | [1] ! Consider running Puma in single-mode (workers = 0) in order to reduce memory overhead.
hellorails-cable-1 | [1] ! Set the `silence_single_worker_warning` option to silence this warning message.
hellorails-cable-1 | [1] - Worker 0 (PID: 11) booted in 0.0s, phase: 0
hellorails-worker-1 | Connection timed out - user specified timeout
hellorails-worker-1 | /usr/local/lib/ruby/3.2.0/socket.rb:65:in `connect_internal'
<trimmed stack>
hellorails-worker-1 exited with code 1
hellorails-web-1 | Started GET "/" for 172.20.0.1 at 2023-09-13 16:11:37 +0000
hellorails-web-1 |
hellorails-web-1 | ActiveRecord::ConnectionNotEstablished (connection to server at "172.20.0.2", port 5432 failed: Connection timed out
hellorails-web-1 | Is the server running on that host and accepting TCP/IP connections?
hellorails-web-1 | ):
After upping the project what does
docker compose ps
show?
jchurch@ubuntu:~/hellorails$ docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
hellorails-cable-1 hellorails-cable "puma -p 28080 cable…" cable About an hour ago Up 9 seconds 8000/tcp, 0.0.0.0:28080->28080/tcp, :::28080->28080/tcp
hellorails-css-1 hellorails-css "yarn build:css" css About an hour ago Up 10 seconds
hellorails-js-1 hellorails-js "yarn build" js About an hour ago Up 10 seconds
hellorails-postgres-1 postgres:15.4-bookworm "docker-entrypoint.s…" postgres 16 hours ago Up 10 seconds 5432/tcp
hellorails-redis-1 redis:7.0.12-bookworm "docker-entrypoint.s…" redis 16 hours ago Up 10 seconds 6379/tcp
hellorails-web-1 hellorails-web "/app/bin/docker-ent…" web About an hour ago Up 9 seconds (health: starting) 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp
If you up the project and in a 2nd terminal run run cmd curl https://example.com
does it successfully connect to the internet and produce a response?
It looks like the app container can't connect over the local Docker network to the local postgres / redis containers but I'd be curious to see if the public network and DNS works in the container.
seemingly no connections at all - internal or external (but still able to make requests to 8000 from the host to web)
curl to localhost does work (returns 500)
jchurch@ubuntu:~/hellorails$ ./run cmd curl https://example.com
curl: (28) Failed to connect to example.com port 443 after 130936 ms: Couldn't connect to server
Task completed in 2m11.105s
jchurch@ubuntu:~/hellorails$ ./run cmd curl http://localhost:8000
<!DOCTYPE html>
<removed- it's the rails console HTML page>
docker execs from the containers show the same thing
jchurch@ubuntu:~/hellorails$ docker exec -it hellorails-web-1 curl -w '\n' http://redis:6379/ping
curl: (28) Failed to connect to redis port 6379 after 129633 ms: Couldn't connect to server
definitely looks like a network comm issue. DNS resolution works because it does turn postgres in to the correct IP.
looks like enable_icc is default (good)
jchurch@ubuntu:~/hellorails$ docker inspect -f '{{index .Options "com.docker.network.bridge.enable_icc"}}' hellorails_default
That's the end of my docker networking knowledge
Hmm, it does look like something on your Docker host is preventing networking from working inside of Docker.
How did you install Docker? Are you running through any proxy or VPN?
no odd networking on the host - it's a ubuntu 20 LTS dev machine running on vmware workstation. Single wired nic with normal routered access to internet, no proxies, vpns, weird DNS, double NAT, etc.
docker install was via the published docker desktop instructions - https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository . I just did their standard 'complete removal' instructions followed by a fresh install, no luck there with a docker compose version of 2.21.0 now.
I've got a great direction to go - really appreciate your help! I'll follow up once I find the resolution but this certainly looks like a 'my machine' issue rather than a package issue
Everything you mentioned looks normal.
On your Docker host can you temporarily modify your /etc/resolv.conf
file to set your nameserver to8.8.8.8
or 1.1.1.1
to see if that makes a difference?
On your Docker host can you temporarily modify your
/etc/resolv.conf
file to set your nameserver to8.8.8.8
or1.1.1.1
to see if that makes a difference?
No luck there :\
I'm happy to call this a 'my machine' and not waste anymore of your time. I really appreciate your help!
I spun a second ubuntu 22 fresh VM, did the docker desktop install and fired the project up the first time with zero issues. docker network inspect
was identical between both machines (minus UIDs.) 🤷
I wonder what it was. If you end up figuring it out let us know by replying here.
I wonder if it was related to iptables rules somehow. That would line up with networking not working.
There's some dragons hidden there around iptables-legacy vs the default although I only ever encountered that when running Debian / Ubuntu inside of WSL 2 where I needed to use iptables-legacy through sudo update-alternatives --config iptables
. I never had to do this on a native Linux system with any distro version.
@nickjj you were right there on the iptables! Looks like somehow I had some leftover snap install hanging around.
https://askubuntu.com/questions/1423293/ubuntu-22-04-docker-containers-not-accessible-from-outside got me working. specifically running:
sudo iptables-legacy -P FORWARD ACCEPT
sudo chmod 666 /var/run/docker.sock
I'm trying to fire up the base example from the readme. All the containers build and seemingly start correctly. However the web server returns ConnectionNotEstablished when trying to connect to postgres and it looks like the workers can't connect to redis (I haven't looked in to that as postgres really blocks anything.)
I can ping and telnet to the postgres server pg port from the host machine. It looks like ping isn't installed on any of the containers so I can't test directly from the webserver.
Any ideas or pointers would be GREATLY appreciated. I'd love to move a bunch of my rails apps over to docker!
Incoming pile of version & environment data - please let me know if anything else would be helpful
app is top of main from yesterday host is ubuntu 20 I have a few other dockers running with networking but nothing seems to collide with the hellorails_default
app build/start output