question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker container fails to start with Python errors

See original GitHub issue

Describe the bug Docker Compose fails to start service and constantly restarts

To Reproduce Steps to reproduce the behavior:

  1. create docker-compose.yml in project
  2. run docker-compose up

Expected behavior The service starts successfully and accepts connections

docker-compose.yml

version: '3.1'

services:
  local-data-api:
    image: koxudaxi/local-data-api
    restart: always
    environment:
      ENGINE: PostgresSQLJDBC
      POSTGRES_HOST: db
      POSTGRES_PORT: 5432
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: secret
      RESOURCE_ARN: 'arn:aws:rds:us-east-1:123456789012:cluster:dummy'
      SECRET_ARN: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:dummy'
    ports:
      - '8080:80'
  db:
    image: mdillon/postgis
    restart: always
    environment:
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: dev
    ports:
      - '5432:5432'

Error Messages

local-data-api_1  | [2020-11-08 11:06:34 +0000] [1] [INFO] Starting gunicorn 20.0.4
local-data-api_1  | [2020-11-08 11:06:34 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
local-data-api_1  | [2020-11-08 11:06:34 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
local-data-api_1  | [2020-11-08 11:06:34 +0000] [7] [INFO] Booting worker with pid: 7
local-data-api_1  | [2020-11-08 11:06:34 +0000] [7] [ERROR] Exception in worker process
local-data-api_1  | Traceback (most recent call last):
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
local-data-api_1  |     worker.init_process()
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/uvicorn/workers.py", line 57, in init_process
local-data-api_1  |     super(UvicornWorker, self).init_process()
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
local-data-api_1  |     self.load_wsgi()
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
local-data-api_1  |     self.wsgi = self.app.wsgi()
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
local-data-api_1  |     self.callable = self.load()
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
local-data-api_1  |     return self.load_wsgiapp()
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
local-data-api_1  |     return util.import_app(self.app_uri)
local-data-api_1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
local-data-api_1  |     mod = importlib.import_module(module)
local-data-api_1  |   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
local-data-api_1  |     return _bootstrap._gcd_import(name[level:], package, level)
local-data-api_1  |   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
local-data-api_1  |   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
local-data-api_1  |   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
local-data-api_1  |   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
local-data-api_1  |   File "<frozen importlib._bootstrap_external>", line 783, in exec_module
local-data-api_1  |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
local-data-api_1  |   File "/app/local_data_api/main.py", line 28, in <module>
local-data-api_1  |     setup()
local-data-api_1  |   File "/app/local_data_api/settings.py", line 58, in setup
local-data-api_1  |     raise NotImplementedError("Engine not already implemented")
local-data-api_1  | NotImplementedError: Engine not already implemented
local-data-api_1  | [2020-11-08 11:06:34 +0000] [7] [INFO] Worker exiting (pid: 7)
local-data-api_1  | {"loglevel": "info", "workers": 1, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
local-data-api_1  | [2020-11-08 11:06:34 +0000] [1] [INFO] Shutting down: Master
local-data-api_1  | [2020-11-08 11:06:34 +0000] [1] [INFO] Reason: Worker failed to boot.
local-data-api_1  | {"loglevel": "info", "workers": 1, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
api_local-data-api_1 exited with code 3

Desktop (please complete the following information):

  • OS: [e.g. iOS] Ubuntu 20.04
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
ablankenship10commented, Nov 9, 2020

Ah hah! Your example above lead me to setting an Endpoint URL in the typeORM ConnectionOptions serviceConfigOptions fields that are passed to the AWS-SDK like so:

{
  type: 'aurora-data-api-pg',
  database: 'devpg',
  secretArn: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:dummy',
  resourceArn: 'arn:aws:rds:us-east-1:123456789012:cluster:dummy',
  region: 'us-east-1',
  serviceConfigOptions: {
    endpoint: 'http://127.0.0.1:8080',
  }
}

Thanks a ton! (And thanks for responding to my email as well!)

0reactions
ablankenship10commented, Nov 9, 2020

Thanks for the link. I’m Using TypeORM (nodejs/typescript) and failing to use an array(string) field. Its supported by Postgres with SQL so unsure why they made a weird API instead of just letting you pass a normal SQL string directly. From what I can tell it is supposed to be supported now via the data api using arrayValues but for some reason the packages im using (data-api-client via TypeORM) are not supporting it yet and that even when they tried it returns Not Supported Error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker container failing with "failed to start a thread for the ...
Whenever I run it with ~1000 urls in the input, it fails with the error "failed to start a thread for the new...
Read more >
Debugging ImportError and ModuleNotFoundErrors in your ...
There are many reasons your Python code might fail to import in Docker. Here's a quick series of checks you can do to...
Read more >
My container does not start and logs are empty
Hi team,. I have created a simple Dockerfile as follow. FROM python:3. RUN apt-get update -y && apt-get install -y python3-pip python-dev.
Read more >
docker container - Python on whales - GitHub Pages
Attach local standard input, output, and error streams to a running container ... from python_on_whales import docker docker.run("ubuntu", ["sleep", ...
Read more >
Containers — Docker SDK for Python 6.0.1 documentation
If the detach argument is True , it will start the container and immediately return a Container object, ... APIError – If the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found