[GH-ISSUE #47] db communication failed #37

Closed
opened 2026-02-25 21:31:04 +03:00 by kerem · 2 comments
Owner

Originally created by @Ylawy on GitHub (Jul 23, 2020).
Original GitHub issue: https://github.com/ciur/papermerge/issues/47

Hi,

I'm a long time Teedy user but wanted to give papermerge a try since the youtube clips look amazing.
However, I'm having trouble setting it up via docker compose.
This is my compose file:

version: '2.0'
services:
  app:
    image: eugenci/papermerge:1.2.3
    container_name: papermerge_service
    command: python3 /opt/papermerge/manage.py runserver 0.0.0.0:8000
    ports:
      - 8222:8000
    depends_on:
      - db
    volumes:
      - /home/a300/apps/papermerge/media_root:/opt/media
      - /home/a300/apps/papermerge/broker_queue:/opt/broker/queue
    environment:
      - DJANGO_SETTINGS_MODULE=config.settings.stage
  db:
    image: postgres:11.7
    container_name: postgres_db
    volumes:
      - /home/a300/apps/papermerge/postgres_data:/var/lib/postgresql/data/
    environment:
      - POSTGRES_USER=dbuser
      - POSTGRES_PASSWORD=dbpass
      - POSTGRES_DB=dbname
  worker:
    image: eugenci/papermerge-worker:1.2.x
    container_name: papermerge_worker
    command: bash -c "cd /opt/papermerge-worker && celery worker -A pmworker.celery -Q papermerge -l info"
    volumes:
      - /home/a300/apps/papermerge/media_root:/opt/media
      - /home/a300/apps/papermerge/broker_queue:/opt/broker/queue
    environment:
      - CELERY_CONFIG_MODULE=config
      - C_FORCE_ROOT=True

worker and db container start just fine and nothing indicates that there is a problem. But the main app gives me the following error:

  File "/usr/local/lib/python3.7/dist-packages/django/utils/asyncio.py", line 26, in inner,
    return func(*args, **kwargs),
  File "/usr/local/lib/python3.7/dist-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection,
    connection = Database.connect(**conn_params),
  File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 126, in connect,
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync),
django.db.utils.OperationalError: could not translate host name "db" to address: No address associated with hostname,

All containers run on bridge network.
Here is the full log file of the app container:
https://pastebin.com/BF5P3JaR
What am I missing here?
Thanks for your help

Originally created by @Ylawy on GitHub (Jul 23, 2020). Original GitHub issue: https://github.com/ciur/papermerge/issues/47 Hi, I'm a long time Teedy user but wanted to give papermerge a try since the youtube clips look amazing. However, I'm having trouble setting it up via docker compose. This is my compose file: ``` version: '2.0' services: app: image: eugenci/papermerge:1.2.3 container_name: papermerge_service command: python3 /opt/papermerge/manage.py runserver 0.0.0.0:8000 ports: - 8222:8000 depends_on: - db volumes: - /home/a300/apps/papermerge/media_root:/opt/media - /home/a300/apps/papermerge/broker_queue:/opt/broker/queue environment: - DJANGO_SETTINGS_MODULE=config.settings.stage db: image: postgres:11.7 container_name: postgres_db volumes: - /home/a300/apps/papermerge/postgres_data:/var/lib/postgresql/data/ environment: - POSTGRES_USER=dbuser - POSTGRES_PASSWORD=dbpass - POSTGRES_DB=dbname worker: image: eugenci/papermerge-worker:1.2.x container_name: papermerge_worker command: bash -c "cd /opt/papermerge-worker && celery worker -A pmworker.celery -Q papermerge -l info" volumes: - /home/a300/apps/papermerge/media_root:/opt/media - /home/a300/apps/papermerge/broker_queue:/opt/broker/queue environment: - CELERY_CONFIG_MODULE=config - C_FORCE_ROOT=True ``` worker and db container start just fine and nothing indicates that there is a problem. But the main app gives me the following error: ``` File "/usr/local/lib/python3.7/dist-packages/django/utils/asyncio.py", line 26, in inner, return func(*args, **kwargs), File "/usr/local/lib/python3.7/dist-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection, connection = Database.connect(**conn_params), File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 126, in connect, conn = _connect(dsn, connection_factory=connection_factory, **kwasync), django.db.utils.OperationalError: could not translate host name "db" to address: No address associated with hostname, ``` All containers run on bridge network. Here is the full log file of the app container: https://pastebin.com/BF5P3JaR What am I missing here? Thanks for your help
kerem 2026-02-25 21:31:04 +03:00
  • closed this issue
  • added the
    docker
    label
Author
Owner

@ciur commented on GitHub (Jul 23, 2020):

This error:

could not translate host name "db" to address: No address associated with hostname,

Basically says that main application was unable to resolve host name - named 'db'. Inside docker image, papermerge application connects to a database located on host named 'db'. It is definitely docker yml file/docker-compose version issue.

Just to be on the safe side: can you please change version of yml file from 2.0 to 3.7?
After you change yml file version, add this at the bottom of the file:

volumes:
  postgres_data:
  broker_queue:
  media_root:

above volumes key is placed on same level as 'services' and 'version' keys:

version: '3.7'
services:
   app: ...
    ...
volumes:
   postgres_data:
   broker_queue:
   media_root:

Also, can you please double check if you use latest docker + docker-compose versions?
Here is what I have on my computer:

(.venv) eugen@dell-xps:docker$ docker-compose --version
docker-compose version 1.26.0, build d4451659
(.venv) eugen@dell-xps:docker$ docker --version
Docker version 19.03.12, build 48a66213fe
<!-- gh-comment-id:662902813 --> @ciur commented on GitHub (Jul 23, 2020): This error: > could not translate host name "db" to address: No address associated with hostname, Basically says that main application was unable to resolve host name - named 'db'. Inside docker image, papermerge application [connects to a database located on host named 'db'](https://github.com/ciur/papermerge/blob/master/docker/app/settings.py#L37). It is definitely docker yml file/docker-compose version issue. Just to be on the safe side: can you please change version of yml file from 2.0 to 3.7? After you change yml file version, add this at the bottom of the file: ``` volumes: postgres_data: broker_queue: media_root: ``` above volumes key is placed on same level as 'services' and 'version' keys: ``` version: '3.7' services: app: ... ... volumes: postgres_data: broker_queue: media_root: ``` Also, can you please double check if you use latest docker + docker-compose versions? Here is what I have on my computer: ``` (.venv) eugen@dell-xps:docker$ docker-compose --version docker-compose version 1.26.0, build d4451659 (.venv) eugen@dell-xps:docker$ docker --version Docker version 19.03.12, build 48a66213fe ```
Author
Owner

@Ylawy commented on GitHub (Jul 23, 2020):

Thanks for your quick reply.

It must have been the version as portainer doesn't support version >2. I got it running now using docker compose outside of Portainer.

<!-- gh-comment-id:662964851 --> @Ylawy commented on GitHub (Jul 23, 2020): Thanks for your quick reply. It must have been the version as portainer doesn't support version >2. I got it running now using docker compose outside of Portainer.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/papermerge#37
No description provided.