Segmentation fault while running python in docker container

Question:

I am trying to run this Github project on docker on my machine. Here is my docker file that I am running after cloning the project on my local machine.

FROM python:3

RUN mkdir -p /opt/cascade-server
WORKDIR /opt/cascade-server
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
COPY docker_defaults.yml conf/defaults.yml

CMD /bin/bash docker_start.sh 

All my configurations are correct and working fine. When I run the project without docker containers, it runs correctly. When I build Docker containers to install it, it does not ends on python cascade.py -vv when running the below shell script from the last line of docker.

#!/bin/bash

if [ -f "conf/cascade.yml" ]; then
   echo "cascade.yml found. Using existing configuration."
else
   echo "cascade.yml not found. Generating new config file from defaults"
   python cascade.py --setup_with_defaults
fi

python cascade.py -vv 

All the logs are showing correct results till the last line executes from the shell script. Here is the error when the last line executes.

<frozen importlib._bootstrap>:241: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 152 from C header, got 160 from PyObject
<frozen importlib._bootstrap>:241: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 152 from C header, got 160 from PyObject
<frozen importlib._bootstrap>:241: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 152 from C header, got 160 from PyObject
<frozen importlib._bootstrap>:241: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 152 from C header, got 160 from PyObject
<frozen importlib._bootstrap>:241: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 152 from C header, got 160 from PyObject
/opt/cascade-server/app/async_wrapper.py:44: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['urllib3.util (/usr/local/lib/python3.10/site-packages/urllib3/util/__init__.py)', 'pymongo.ssl_context (/usr/local/lib/python3.10/site-packages/pymongo/ssl_context.py)', 'urllib3.util.ssl_ (/usr/local/lib/python3.10/site-packages/urllib3/util/ssl_.py)']. 
  gevent.monkey.patch_all()
docker_start.sh: line 10:    18 Segmentation fault      (core dumped) python cascade.py -vv
 

python version

enter image description here

Asked By: JAMSHAID

||

Answers:

try to change the base image python:3 (which use Python 3.10) to python:3.7 base image like your local Python interpreter.

Answered By: ItayB
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.