Docker install failing on debian with pymongo error

Hi all,

I have been scratching my head trying to deploy newsblur through docker on the following:

  • Debian 12 container with docker v24.0.7 installed running on proxmox
  • Debian 12 VM with docker v 24.0.7 installed running on proxmox
  • Debian 11 container with docker v24.0.7 installed running on proxmox

As I was trying to identify whether the issue could be related to debian, but I consistently get the following trace and have to use “sudo make nb” in addition to changing the imageproxy container image from arm64 to default one since I run this on top of x86/amd64.

Would anybody have an idea of what the cause of this issue could be?

sudo make nb
docker pull newsblur/newsblur_python3
Using default tag: latest
latest: Pulling from newsblur/newsblur_python3
Digest: sha256:e9c2164d83febaecd59dc26fd6326686a69be23ba2cb1ffe8fce796a6403439c
Status: Image is up to date for newsblur/newsblur_python3:latest
docker.io/newsblur/newsblur_python3:latest
docker pull newsblur/newsblur_node
Using default tag: latest
latest: Pulling from newsblur/newsblur_node
Digest: sha256:307471b66f895bb24ad924322b0c8cf0f6afa908fcee380aa5489615a2ad1859
Status: Image is up to date for newsblur/newsblur_node:latest
docker.io/newsblur/newsblur_node:latest
docker pull newsblur/newsblur_monitor
Using default tag: latest
latest: Pulling from newsblur/newsblur_monitor
Digest: sha256:a8378dd239c185d5180f45d7069e62b1d9898f5f20d80618303f4939443e7a4d
Status: Image is up to date for newsblur/newsblur_monitor:latest
docker.io/newsblur/newsblur_monitor:latest
RUNWITHMAKEBUILD=True CURRENT_UID=0 CURRENT_GID=0 docker compose down
[[ -d config/certificates ]] && echo "keys exist" || make keys
keys exist
RUNWITHMAKEBUILD=True CURRENT_UID=0 CURRENT_GID=0 docker compose up -d --build --remove-orphans
[+] Running 12/12
 ✔ Network newsblur_default    Created                                                                                                                                    0.1s 
 ✔ Container task_celery       Started                                                                                                                                    4.1s 
 ✔ Container dejavu            Started                                                                                                                                    4.1s 
 ✔ Container db_redis          Started                                                                                                                                    4.1s 
 ✔ Container db_postgres       Started                                                                                                                                    4.1s 
 ✔ Container db_mongo          Started                                                                                                                                    4.1s 
 ✔ Container db_elasticsearch  Started                                                                                                                                    4.1s 
 ✔ Container imageproxy        Started                                                                                                                                    4.1s 
 ✔ Container node              Started                                                                                                                                    4.9s 
 ✔ Container newsblur_web      Started                                                                                                                                    4.9s 
 ✔ Container nginx             Started                                                                                                                                    0.0s 
 ✔ Container haproxy           Started                                                                                                                                    5.2s 
docker exec -it newsblur_web ./manage.py migrate
 ---> Starting NewsBlur development server...
Operations to perform:
  Apply all migrations: admin, analyzer, auth, contenttypes, django_ses, feed_import, ipn, oauth2_provider, profile, push, reader, recommendations, rss_feeds, sessions, sites, social, zebra
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying rss_feeds.0001_initial... OK
  Applying analyzer.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying django_ses.0001_initial... OK
  Applying feed_import.0001_initial... OK
  Applying ipn.0001_initial... OK
  Applying ipn.0002_paypalipn_mp_id... OK
  Applying ipn.0003_auto_20141117_1647... OK
  Applying ipn.0004_auto_20150612_1826... OK
  Applying ipn.0005_auto_20151217_0948... OK
  Applying ipn.0006_auto_20160108_1112... OK
  Applying ipn.0007_auto_20160219_1135... OK
  Applying ipn.0008_auto_20181128_1032... OK
  Applying oauth2_provider.0001_initial... OK
  Applying oauth2_provider.0002_auto_20190406_1805... OK
  Applying profile.0001_initial... OK
  Applying profile.0002_auto_20200620_0803... OK
  Applying profile.0003_auto_20201005_0932... OK
  Applying profile.0004_auto_20220110_2106... OK
  Applying profile.0005_profile_is_archive... OK
  Applying profile.0006_profile_days_of_unread... OK
  Applying profile.0007_auto_20220125_2108... OK
  Applying profile.0008_profile_paypal_sub_id... OK
  Applying profile.0009_paypalids... OK
  Applying profile.0010_profile_active_provider... OK
  Applying profile.0011_auto_20220408_1908... OK
  Applying profile.0012_auto_20220511_1710... OK
  Applying push.0001_initial... OK
  Applying reader.0001_initial... OK
  Applying recommendations.0001_initial... OK
  Applying rss_feeds.0002_remove_mongo_types...Traceback (most recent call last):
  File "/srv/newsblur/./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 243, in handle
    post_migrate_state = executor.migrate(
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/srv/newsblur/apps/rss_feeds/migrations/0002_remove_mongo_types.py", line 8, in remove_mongo_types
    collections = db.collection_names()
  File "/usr/local/lib/python3.9/site-packages/pymongo/database.py", line 1005, in collection_names
    for result in self.list_collections(session=session, nameOnly=True, **kws)
  File "/usr/local/lib/python3.9/site-packages/pymongo/database.py", line 943, in list_collections
    return self.__client._retryable_read(_cmd, read_pref, session)
  File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1606, in _retryable_read
    server = self._select_server(read_pref, session, address=address)
  File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1436, in _select_server
    server = topology.select_server(server_selector)
  File "/usr/local/lib/python3.9/site-packages/pymongo/topology.py", line 250, in select_server
    return random.choice(self.select_servers(selector, server_selection_timeout, address))
  File "/usr/local/lib/python3.9/site-packages/pymongo/topology.py", line 211, in select_servers
    server_descriptions = self._select_servers_loop(selector, server_timeout, address)
  File "/usr/local/lib/python3.9/site-packages/pymongo/topology.py", line 226, in _select_servers_loop
    raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: db_mongo:29019: [Errno -2] Name or service not known, Timeout: 30s, Topology Description: <TopologyDescription id: 659b301f2bb909b0fbfc0520, topology_type: Single, servers: [<ServerDescription ('db_mongo', 29019) server_type: Unknown, rtt: None, error=AutoReconnect('db_mongo:29019: [Errno -2] Name or service not known')>]>
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit
make: *** [Makefile:38: migrate] Error 1

It looks like the mongo db keeps crashing for some reasons:

docker ps 
CONTAINER ID   IMAGE                                                  COMMAND                  CREATED         STATUS                            PORTS                                                                                                                 NAMES
92aff5c85b63   haproxy:latest                                         "docker-entrypoint.s…"   9 minutes ago   Up 8 minutes                      0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:1936->1936/tcp, :::1936->1936/tcp   haproxy
1dfdd1975b06   nginx:1.19.6                                           "/docker-entrypoint.…"   9 minutes ago   Up 9 minutes                      80/tcp, 0.0.0.0:81->81/tcp, :::81->81/tcp                                                                             nginx
4dc1ae168e82   newsblur/newsblur_python3:latest                       "/bin/sh -c newsblur…"   9 minutes ago   Up 9 minutes                      0.0.0.0:8000->8000/tcp, :::8000->8000/tcp                                                                             newsblur_web
2a7a349817d4   newsblur/newsblur_node:latest                          "docker-entrypoint.s…"   9 minutes ago   Up 9 minutes                      0.0.0.0:8008->8008/tcp, :::8008->8008/tcp                                                                             node
a59c93a36a23   docker.elastic.co/elasticsearch/elasticsearch:7.16.3   "/bin/tini -- /usr/l…"   9 minutes ago   Up 13 seconds                     0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp                                  db_elasticsearch
970908604c1f   appbaseio/dejavu:3.6.0                                 "docker-entrypoint.s…"   9 minutes ago   Up 9 minutes                      0.0.0.0:1358->1358/tcp, :::1358->1358/tcp                                                                             dejavu
9ebdd0336691   redis:latest                                           "docker-entrypoint.s…"   9 minutes ago   Up 9 minutes                      6379/tcp, 0.0.0.0:6579->6579/tcp, :::6579->6579/tcp                                                                   db_redis
e88bc8268f5b   mongo:4.0                                              "docker-entrypoint.s…"   9 minutes ago   Restarting (100) 57 seconds ago                                                                                                                         db_mongo
b673a863b1d1   newsblur/newsblur_python3                              "celery worker -A ne…"   9 minutes ago   Up 9 minutes                                                                                                                                            task_celery
0390569f03db   postgres:13.1                                          "docker-entrypoint.s…"   9 minutes ago   Up 9 minutes                      0.0.0.0:5434->5432/tcp, :::5434->5432/tcp                                                                             db_postgres
7c4283d9ea25   ghcr.io/willnorris/imageproxy:latest                   "/app/imageproxy -ad…"   9 minutes ago   Up 9 minutes                      8080/tcp, 0.0.0.0:8088->8088/tcp, :::8088->8088/tcp      

Not trying to be difficult but it is not very clear what needs to be modified in the docker-compose YAML file as I guess something is missing, question is where? Looking at the logs from the restarting container?

docker compose logs -f db_mongo
WARN[0000] The "CURRENT_UID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "CURRENT_GID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "CURRENT_UID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "CURRENT_GID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "CURRENT_UID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "CURRENT_GID" variable is not set. Defaulting to a blank string. 
parsing /srv/newsblur/docker-compose.yml: error while interpolating services.newsblur_web.environment.[]: required variable RUNWITHMAKEBUILD is missing a value: Use the `make` command instead of docker CLI